/*
 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
 * Digest Algorithm, as defined in RFC 1321.
 * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
 * Distributed under the BSD License
 * See http://pajhome.org.uk/crypt/md5 for more info.
 */

/*
 * Configurable variables. You may need to tweak these to be compatible with
 * the server-side, but the defaults work in most cases.
 */
var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance   */
var chrsz = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */

/*
 * These are the functions you'll usually want to call
 * They take string arguments and return either hex or base-64 encoded strings
 */
function hex_md5(s) {
    return binl2hex(core_md5(str2binl(s), s.length * chrsz));
}

function b64_md5(s) {
    return binl2b64(core_md5(str2binl(s), s.length * chrsz));
}

function str_md5(s) {
    return binl2str(core_md5(str2binl(s), s.length * chrsz));
}

function hex_hmac_md5(key, data) {
    return binl2hex(core_hmac_md5(key, data));
}

function b64_hmac_md5(key, data) {
    return binl2b64(core_hmac_md5(key, data));
}

function str_hmac_md5(key, data) {
    return binl2str(core_hmac_md5(key, data));
}

/*
 * Perform a simple self-test to see if the VM is working
 */
function md5_vm_test() {
    return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
}

/*
 * Calculate the MD5 of an array of little-endian words, and a bit length
 */
function core_md5(x, len) {
    /* append padding */
    x[len >> 5] |= 0x80 << ((len) % 32);
    x[(((len + 64) >>> 9) << 4) + 14] = len;

    var a = 1732584193;
    var b = -271733879;
    var c = -1732584194;
    var d = 271733878;

    for (var i = 0; i < x.length; i += 16) {
        var olda = a;
        var oldb = b;
        var oldc = c;
        var oldd = d;

        a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
        d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
        c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
        b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
        a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
        d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
        c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
        b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
        a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
        d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
        c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
        b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
        a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
        d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
        c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
        b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);

        a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
        d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
        c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
        b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
        a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
        d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
        c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
        b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
        a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
        d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
        c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
        b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
        a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
        d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
        c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
        b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);

        a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
        d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
        c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
        b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
        a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
        d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
        c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
        b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
        a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
        d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
        c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
        b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
        a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
        d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
        c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
        b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);

        a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
        d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
        c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
        b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
        a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
        d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
        c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
        b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
        a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
        d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
        c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
        b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
        a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
        d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
        c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
        b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);

        a = safe_add(a, olda);
        b = safe_add(b, oldb);
        c = safe_add(c, oldc);
        d = safe_add(d, oldd);
    }
    return Array(a, b, c, d);

}

/*
 * These functions implement the four basic operations the algorithm uses.
 */
function md5_cmn(q, a, b, x, s, t) {
    return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
}

function md5_ff(a, b, c, d, x, s, t) {
    return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}

function md5_gg(a, b, c, d, x, s, t) {
    return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}

function md5_hh(a, b, c, d, x, s, t) {
    return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}

function md5_ii(a, b, c, d, x, s, t) {
    return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}

/*
 * Calculate the HMAC-MD5, of a key and some data
 */
function core_hmac_md5(key, data) {
    var bkey = str2binl(key);
    if (bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);

    var ipad = Array(16), opad = Array(16);
    for (var i = 0; i < 16; i++) {
        ipad[i] = bkey[i] ^ 0x36363636;
        opad[i] = bkey[i] ^ 0x5C5C5C5C;
    }

    var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
    return core_md5(opad.concat(hash), 512 + 128);
}

/*
 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
 * to work around bugs in some JS interpreters.
 */
function safe_add(x, y) {
    var lsw = (x & 0xFFFF) + (y & 0xFFFF);
    var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
    return (msw << 16) | (lsw & 0xFFFF);
}

/*
 * Bitwise rotate a 32-bit number to the left.
 */
function bit_rol(num, cnt) {
    return (num << cnt) | (num >>> (32 - cnt));
}

/*
 * Convert a string to an array of little-endian words
 * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
 */
function str2binl(str) {
    var bin = Array();
    var mask = (1 << chrsz) - 1;
    for (var i = 0; i < str.length * chrsz; i += chrsz)
        bin[i >> 5] |= (str.charCodeAt(i / chrsz) & mask) << (i % 32);
    return bin;
}

/*
 * Convert an array of little-endian words to a string
 */
function binl2str(bin) {
    var str = "";
    var mask = (1 << chrsz) - 1;
    for (var i = 0; i < bin.length * 32; i += chrsz)
        str += String.fromCharCode((bin[i >> 5] >>> (i % 32)) & mask);
    return str;
}

/*
 * Convert an array of little-endian words to a hex string.
 */
function binl2hex(binarray) {
    var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
    var str = "";
    for (var i = 0; i < binarray.length * 4; i++) {
        str += hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8 + 4)) & 0xF) +
            hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8)) & 0xF);
    }
    return str;
}

/*
 * Convert an array of little-endian words to a base-64 string
 */
function binl2b64(binarray) {
    var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    var str = "";
    for (var i = 0; i < binarray.length * 4; i += 3) {
        var triplet = (((binarray[i >> 2] >> 8 * (i % 4)) & 0xFF) << 16)
            | (((binarray[i + 1 >> 2] >> 8 * ((i + 1) % 4)) & 0xFF) << 8)
            | ((binarray[i + 2 >> 2] >> 8 * ((i + 2) % 4)) & 0xFF);
        for (var j = 0; j < 4; j++) {
            if (i * 8 + j * 6 > binarray.length * 32) str += b64pad;
            else str += tab.charAt((triplet >> 6 * (3 - j)) & 0x3F);
        }
    }
    return str;
}


String.prototype.replaceAll = function (f, e) {//吧f替换成e
    var reg = new RegExp(f, "g"); //创建正则RegExp对象
    return this.replace(reg, e);
}
var njzxw = {
    cookie: {
        setCookie: function (name, value) {
            var Days = 30;
            var exp = new Date();
            exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
            document.cookie = name + "=" + escape(value) + ";path=/;expires=" + exp.toGMTString();
        },
        getCookie: function (name) {
            var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
            if (arr = document.cookie.match(reg))
                return unescape(arr[2]);
            else
                return null;
        },
        delCookie: function (name) {
            var exp = new Date();
            exp.setTime(exp.getTime() - 1);
            var cval = getCookie(name);
            if (cval != null)
                document.cookie = name + "=" + cval + ";path=/;expires=" + exp.toGMTString();
        }
    },
    load: {
        index: null,
        show: function () {
            if ($('#layui-layer-shade').size() == 0 && $('#layui-layer-shade_zxw').size() == 0) {
                njzxw.load.index = layui.layer.load(2, {time: 0, shade: 0.5, skin: 'zxw-loang'});
            }
        },
        hide: function () {
            $('#layui-layer-shade_zxw').fadeOut(1000, function (e) {
                $('#layui-layer-shade_zxw').remove();
            });
            $('#layui-layer_zxw').fadeOut(1000, function () {
                $('#layui-layer-shade_zxw').remove();
            });
            if (njzxw.load.index != null) {
                $('.layui-layer-shade').fadeOut(1000, function (e) {
                    $('.layui-layer-shade').remove();
                    njzxw.load.index = null;
                });
                $('.layui-layer-loading').fadeOut(1000, function () {
                    $('.layui-layer-loading').remove();
                    njzxw.load.index = null;
                });
            }
        }
    },
    /**
     * 转换form表单数据
     * @param id
     * @returns {*}
     */
    formData: function (id) {
        var array = $(id).serializeArray();
        // console.log(array);
        var data_ = {};

        //检查页面是否存在多级
        var mult = $('#mult').val();
        var mult_ = [];
        if ($.trim(mult) != '') {
            mult_ = mult.split(',');
        }

        for (var i = 0, cnt = array.length; i < cnt; i++) {
            var name = array[i].name;
            var value = array[i].value;

            //key在之前的数据中不存在，并且在页面指定多数据中也不存在就直接是key=value 否则是key=[value,value]形式
            if (!data_.hasOwnProperty(name) && !checkMult(name)) {
                data_[name] = value;
            } else {
                var val = data_[name];
                if (!$.isArray(val)) {
                    var d = [];
                    if (val != undefined) {
                        d.push(val);
                    }

                    d.push(value);
                    data_[name] = d;
                } else {
                    val.push(value);
                    data_[name] = val;
                }
            }
        }

        function checkMult(name) {
            for (var i = 0; i < mult_.length; i++) {
                if ($.trim(mult_[i]) == name) {
                    return true;
                }
            }
            return false;
        }

        data_['token'] = njzxw.cookie.getCookie('token');
        data_['requset_type'] = "web后台管理";

        return data_;
    },
    /**
     * 摇晃提醒
     * @param obj jquery选择器
     */
    shake: function (obj) {
        $(obj).each(function (i, n) {
            $(n).addClass('myerror_');
            setTimeout(function () {
                $(n).removeClass('myerror_');
            }, 1000);
        });
    },
    /**
     * 是否是手机访问
     * @returns {boolean}
     */
    isMobile: function () {
        var ua = navigator.userAgent;

        var ipad = ua.match(/(iPad).*OS\s([\d_]+)/),

            isIphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/),

            isAndroid = ua.match(/(Android)\s+([\d.]+)/),

            isMobile = isIphone || isAndroid;

        if (isMobile) {
            return true;
        } else {
            return false;
        }
    },
    /**
     * 删除操作
     */
    delete: function (opt) {
        this.alert({
            msg: opt.msg,
            type: 'confirm',
            fun: function (cl) {
                cl();
                njzxw.ajax({
                    url: opt.url,
                    data: opt.data,
                    fun: function (a, b) {
                        if (a) {
                            if (b.state == 1) {
                                njzxw.alert({
                                    msg: b.msg,
                                    fun: function (a) {
                                        a();
                                        parent.index.refresh();
                                    }
                                });
                            } else {
                                njzxw.alert({
                                    msg: b.msg,
                                    error: true
                                });
                            }
                        } else {
                            njzxw.alert({
                                msg: '请求错误，请重新操作',
                                error: true
                            });
                        }
                    }
                });
            }
        })
    },
    /**
     * 对话框
     * @param opt
     */
    alert: function (opt) {
        if (opt.type == 'confirm') {
            layui.layer.confirm(
                opt.msg,
                {
                    icon: opt.icon == undefined ? 3 : opt.icon,
                    title: opt.title == undefined ? '系统提示' : opt.title,
                    closeBtn: 0,
                    scrollbar: false
                },
                function (index) {
                    if (typeof (opt.fun) == 'function') {
                        opt.fun(function () {
                            layer.close(index);
                        });
                    } else {
                        layer.close(index);
                    }
                });
        } else {
            layui.layer.alert(
                opt.msg, {
                    icon: opt.error == true ? 5 : 6,
                    closeBtn: 0,
                    scrollbar: false
                }, function (index) {
                    if (typeof (opt.fun) == 'function') {
                        opt.fun(function () {
                            layer.close(index);
                        });
                    } else {
                        layer.close(index);
                    }
                });
        }
    },
    /**
     * 获取参数对应值
     */
    getQueryParamsString: function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);  //获取url中"?"符后的字符串并正则匹配
        var context = "";
        if (r != null)
            context = r[2];
        reg = null;
        r = null;
        return context == null || context == "" || context == "undefined" ? "" : context;
    },
    /**
     * ajax封装
     */
    ajax: function (opt) {

        if (typeof (opt.data) == 'undefined') {
            opt.data = {};
        }

        if (opt.contentType == undefined) {
            opt.data.token = njzxw.cookie.getCookie('token');
        }
        opt.data.requset_type = "web后台管理";

        var defaut = {
            url: opt.url,
            type: opt.type != undefined ? opt.type : 'POST',
            data: JSON.stringify(opt.data != undefined ? opt.data : {}),
            dataType: opt.dataType != undefined ? opt.dataType : 'json',
            contentType: opt.contentType != undefined ? opt.contentType : 'application/json;charset=utf-8',
            xhrFields: {
                'Access-Control-Allow-Origin': '*'
            },
            crossDomain: true,
            timeout: 1000 * 60 * 3,
            success: function (data, textStatus) {
                if (typeof (opt.fun) == 'function') {
                    opt.fun(true, data);
                } else {
                    if (data.state == 1) {
                        layui.layer.alert(data.msg, function () {
                            parent.index.refresh();
                        });
                    } else {
                        layui.layer.alert(data.msg);
                    }
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.error(XMLHttpRequest, textStatus, errorThrown);
                // alert(233);
                if (XMLHttpRequest.status == 510) {//未登录
                    // alert(2);
                    // njzxw.alert({
                    //     error:true,
                    //     msg:'您还未登录或登录失效，请重新登录',
                    //     fun:function(){
                    //         window.top.location.href = own.config.localhostPath+'/html/login.html';
                    //     }
                    // });
                    return;
                } else if (XMLHttpRequest.status == 511) {//没有权限
                    // njzxw.alert({
                    //     msg:'您未授权，请联系管理员添加访问权限。',
                    //     error:true
                    // });
                    return;
                }
                if (typeof (opt.fun) == 'function') {
                    opt.fun(false, errorThrown);
                } else {
                    njzxw.alert({
                        msg: '请求错误，请重新操作。',
                        error: true
                    });
                }
            }
        }
        console.log("请求信息===>:", defaut);
        $.ajax(defaut);
    },
    /**
     * 动画处理
     */
    anim: {
        /**
         * 开始动画
         *
         * 默认参数：def = {
     id: null,
     animatClass: '',
     endFun: function () {

     },
     time: 0.2
     }
         *
         * @param {type} id jqeury选择器
         * @param {type} animatClass Animate.css 中的动画className
         * @param {type} endFun 运动结束后执行的参数
         * @returns {undefined}
         */
        startAnim: function (opt) {
            var def = {
                id: null,
                animatClass: '',
                endFun: function (e) {

                },
                time: '0.2'
            };
            $.extend(def, opt);
            $(def.id).removeClass('animated ' + def.animatClass).css("animation-duration", "");
            $(def.id).addClass('animated ' + def.animatClass);
            if (def.time != undefined && def.time != null) {
                $(def.id).css("animation-duration", def.time + "s");
            }
            njzxw.anim.addAnimEndEvent(def.id, function (e) {
                $(e).removeClass('animated ' + def.animatClass).css("animation-duration", "");
                if (typeof (def.endFun) == 'function') {
                    def.endFun(e);
                }
            });
        },
        /**
         * 结束动画
         *
         * @param {type} id jqeury选择器
         * @param {type} animatClass Animate.css 中的动画className
         * @returns {undefined}
         */
        endAnim: function (id, animatClass) {
            $(id).removeClass('animated ' + animatClass);
        },
        /**
         * 添加动画结束事件
         *
         * @param {type} id
         * @param {type} fun
         * @returns {undefined}
         */
        addAnimEndEvent: function (id, fun) {

            if (Modernizr.csstransforms) {
                $(id).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function (e) {
                    fun(this, e);
                    $(id).unbind();
                });
            } else {
                fun($(id), null);
                $(id).unbind();
            }

        }
    },
    showphotos: function (src) {
        layui.layer.photos({
            photos: {
                "title": "", //相册标题
                "id": 123, //相册id
                "start": 0, //初始显示的图片序号，默认0
                "data": [   //相册包含的图片，数组格式
                    {
                        "alt": "",
                        "pid": 0, //图片id
                        "src": src, //原图地址
                        "thumb": "" //缩略图地址
                    }
                ]
            },
            anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机
        });
    },
    /**
     * 进行权限控制 true能访问 false 不能访问
     */
    checkControl: function (control) {
        if (typeof (control) == 'object') {
            control = $(control).attr('control');
        }

        if (control != undefined && control != null && $.trim(control) != '') {//存在值
            var controls = control.split('|');

            for (var i = 0; i < controls.length; i++) {
                var array = njzxw.localStorage.getYs('control');
                if (array.indexOf(hex_md5($.trim(controls[i]))) > 0) {
                    return true;
                }
            }
            return false;
        }
        return true;
    },
    layui: {
        /**
         * 初始化组件
         */
        init: function (ops) {
            this.select();
            this.bnt();
            this.multipleUpload();
            this.signUpload();
            this.input();
            this.textarea();
            this.switch();
            this.checkbox();
            this.inputTime();
            this.table();
            this.img();
            if (ops != undefined) {
                if (typeof (ops.fun) == 'function') {
                    ops.fun();
                }
            }
            this.showWindwo();
            this.verify({});

            $('.moreBtn_').click(function () {
                if ($('.showdown_:visible').size() > 0) {
                    $('.showdown_').css('display', 'none');
                    $(this).html('展开条件 <i class="layui-icon layui-icon-down"></i>');
                } else {
                    $('.showdown_').css('display', 'inline');
                    $(this).html('收起条件 <i class="layui-icon layui-icon-up"></i>');
                }
                return false;
            });

        },
        checkbox: function () {
            $('zxw\\:checkbox').each(function (i, n) {
                var ops = {};
                var $this = $(this);
                var atts = $this[0].attributes;
                for (var i = 0; i < atts.length; i++) {
                    var name = atts[i].name;
                    var value = atts[i].value;
                    if (value != undefined && value != null && value != '') {
                        ops[name] = value == 'true' ? true : value == 'false' ? false : value;
                    }
                }

                ops.lay_verType = $this.attr('lay_verType');
                if ($.trim(ops.lay_verType) == '') {
                    ops.lay_verType = 'tips';
                }

                //获取url
                var u = ops.url;
                var whindex = u.indexOf('\?');
                var url_ = '';
                var params = '';

                if (ops.isitem) {
                    url_ = URL.ITEM.GETITEM;
                    params = "group_id=" + ops.url;
                } else {
                    url_ = whindex > 0 ? u.substring(0, whindex) : u;
                    params = whindex > 0 ? u.substring(whindex + 1) : '';
                    if (url_.indexOf('/') == -1) {
                        url_ = eval(whindex > 0 ? url_.substring(0, whindex) : url_);
                    }
                }

                var data = {};
                if (params != '') {
                    var params_ = params.split('&');
                    var cnt = params_.length;
                    for (var i = 0; i < cnt; i++) {
                        data[params_[i].split('=')[0]] = params_[i].split('=')[1];
                    }
                }

                njzxw.ajax({
                    url: url_,
                    data: data,
                    fun: function (a, b) {
                        if (a) {
                            if (b.state == 1) {
                                var input = '';
                                for (var i = 0; i < b.data.length; i++) {
                                    var id = b.data[i][ops.field_value_key];
                                    var name = b.data[i][ops.field_name_key];
                                    var lay_skin = "";
                                    if ($.trim(ops.lay_skin) == 'true') {
                                        lay_skin = "lay-skin=\"primary\"";
                                    }
                                    input += '<input value="' + id + '" lay-filter="' + ops.id + 'checkbox_filter" type="checkbox" name="' + (ops.id + '[' + id + ']') + '" title="' + name + '" ' + lay_skin + ' >';
                                }
                                var remark_k = $.trim(ops.remark) != '' ? '<i class="layui-icon tip_' + ops.id + ' label_tip layui-icon-about"></i>' : '';

                                var html = "";
                                if (ops.parcel == true) {
                                    html = (ops.inline != true ? '<div style="' + (remark_k == '' ? '' : 'margin-bottom:0px;') + '" class="layui-form-item ' + ops.colclass + '">\n' : '') +
                                        (ops.inline == true ? '<div class="layui-form-item layui-inline ' + (ops.parcelclass != undefined ? ops.parcelclass : '') + ' ">' : '') +
                                        '            <label class="layui-form-label">' + ops.parcelname + (($.trim(ops.lay_verify).indexOf('required') >= 0) ? '<i class="layui-icon" style="font-size: 15px; color: red;">*</i>' : '') + ((remark_k == '' ? '' : remark_k)) + '</label>\n' +
                                        '            <div class="' + (ops.inline == true ? 'layui-input-inline' : 'layui-input-block') + '">\n' +
                                        input +
                                        '            </div>\n' +
                                        (ops.inline == true ? '</div>' : '') +
                                        (ops.inline != true ? '</div' : '');
                                } else {
                                    html = input;
                                }

                                $this.replaceWith(html);

                                layui.form.render('checkbox');
                                //添加对应的事件选择
                                layui.form.on('checkbox(' + ops.id + 'checkbox_filter)', function (data) {
                                    console.log(data.elem); //得到checkbox原始DOM对象
                                    console.log(data.elem.checked); //是否被选中，true或者false
                                    console.log(data.value); //复选框value值，也可以通过data.elem.value得到
                                    console.log(data.othis); //得到美化后的DOM对象
                                });
                            }
                        }
                    }
                });


            });
        },
        ismotion: 0,
        /**
         * 检查是否是在当前页面打开窗口，不是单独打开窗口
         */
        showWindwo: function () {
            if (njzxw.getQueryParamsString('window') == 'false') {
                var savebnt = 'savebnt' + (parseInt(Math.random() * 100));
                var resetbnt = 'savebnt' + (parseInt(Math.random() * 100));
                var lingcunbnt = 'savebnt' + (parseInt(Math.random() * 100));
                var huanybnt = 'savebnt' + (parseInt(Math.random() * 100));
                var tishidiv = 'tishidiv' + (parseInt(Math.random() * 100));
                var maxFramebnt = 'maxFramediv' + (parseInt(Math.random() * 100));
                var restorebnt = 'restorediv' + (parseInt(Math.random() * 100));
                var html = "<div class=\"layui-njzxw-btn layui-layer-btn layui-layer-btn-\" style=\"\n" +
                    "    position: fixed;\n" +
                    "    text-align: center;\n" +
                    "    bottom: 0px;    width: 100%;z-index: 4;\">" +
                    "        <div id='" + tishidiv + "' ></div>" +
                    "        <a id='" + savebnt + "' class=\"layui-layer-btn0\"><i></i>保存</a>\n" +
                    "        <a id='" + resetbnt + "' class=\"layui-layer-btn1\">重置</a>\n" +
                    "        <a id='" + lingcunbnt + "' class=\"layui-layer-btn2\">存储为草稿</a>\n" +
                    "        <a id='" + huanybnt + "' style='display: none;' class=\"layui-layer-btn3\">还原最近一次存储草稿</a>\n" +
                    "        <a id='" + maxFramebnt + "' class=\"layui-layer-btn4\">最大化当前窗口</a>\n" +
                    "        <a id='" + restorebnt + "' style='display: none;' class=\"layui-layer-btn4\">还原当前窗口大小</a>\n" +
                    "    </div>";
                $('body').append(html);

                $('.btn_ a').each(function () {
                    var obj = $(this).clone(true);
                    $('.layui-njzxw-btn').append(obj);
                    $(this).remove();
                });

                var id = window.location.href;
                $('form').css({'margin-bottom': '80px'});

                $('#' + maxFramebnt).click(function () {
                    window.top.index.maxFrameTab();
                    $('#' + restorebnt).show();
                    $(this).hide();
                });
                $('#' + restorebnt).click(function () {
                    window.top.index.restoreFrameTab();
                    $(this).hide();
                    $('#' + maxFramebnt).show();
                });
                $('#' + savebnt).click(function () {
                    njzxw.alert({
                        type: 'confirm',
                        msg: '确定要提交保存吗？',
                        fun: function (close) {
                            $(".njzxw-submit").click();
                            close();
                        }
                    });
                });
                $('#' + resetbnt).click(function () {
                    njzxw.alert({
                        type: 'confirm',
                        msg: '确定要重置吗？',
                        fun: function (close) {
                            $(".njzxw-reset").click();
                            close();
                        }
                    });

                });
                var objt = null;
                $('#' + lingcunbnt).click(function () {
                    var datas = njzxw.formData('form');
                    // console.log(datas);
                    njzxw.localStorage.remove(id);
                    var time = layui.util.toDateString(new Date(), 'yyyy-MM-dd HH:mm:ss');
                    njzxw.localStorage.add(id, {
                        time: time,
                        data: datas
                    });
                    if (njzxw.layui.ismotion == 0) {
                        njzxw.alert({
                            msg: '草稿存储成功'
                        });
                    } else {
                        njzxw.layui.ismotion = 0;
                    }


                    $('#' + tishidiv).text("  草稿存储提示：[" + time + "]时间存储草稿成功");
                    $('#' + huanybnt).css('display', 'inline-block');
                    if (objt != null) {
                        window.clearTimeout(objt);
                    }
                    objt = window.setTimeout(function () {
                        $('#' + tishidiv).text('');
                    }, 3000);
                });
                $('#' + huanybnt).click(function () {

                    var hisdata_ = njzxw.localStorage.get(id);
                    if (typeof (hisdata_) == 'object') {//存在历史值
                        njzxw.alert({
                            msg: '确定要还原时间点[' + hisdata_.time + ']存储的草稿吗？',
                            type: 'confirm',
                            title: '还原提示',
                            fun: function (a) {
                                a();
                                njzxw.restore(id);
                            }
                        });
                    } else {
                        njzxw.alert({
                            error: true,
                            msg: '暂无数据可还原'
                        });
                    }
                });
                var hisdata = njzxw.localStorage.get(id);
                if (typeof (hisdata) == 'object' && hisdata != null) {
                    $('#' + huanybnt).css('display', 'inline-block');
                }
                //自动保存
                window.setInterval(function () {
                    njzxw.layui.ismotion = 1;
                    $('#' + lingcunbnt).click();
                }, 3 * 60 * 1000);

                //添加快捷键操作
                document.onkeydown = function (e) {
                    var keyCode = e.keyCode || e.which || e.charCode;
                    var ctrlKey = e.metaKey;
                    // console.log(ctrlKey,keyCode);
                    if (ctrlKey && keyCode == 82) {//刷新 mac
                        window.location.reload(true);
                        e.preventDefault();
                        return false;
                    } else if (ctrlKey && keyCode == 83) {//保存操作
                        $('#' + savebnt).click();
                        e.preventDefault();
                        return false;
                    } else if (ctrlKey && keyCode == 90) {//切换最大最小
                        if (window.top.index.isMacFrame()) {
                            $('#' + restorebnt).click();
                        } else {
                            $('#' + maxFramebnt).click();
                        }
                        e.preventDefault();
                        return false;
                    }

                }
            }

        },
        inputTime: function () {
            $("zxw\\:inputTime").each(function (i, n) {
                var ops = {};
                var $this = $(this);
                var atts = $this[0].attributes;
                console.log(atts);
                for (var i = 0; i < atts.length; i++) {
                    var name = atts[i].name;
                    var value = atts[i].value;
                    if (value != undefined && value != null && value != '') {
                        ops[name] = value == 'true' ? true : value == 'false' ? false : value;
                    }
                }
                if (!ops.rangenum) ops.rangenum = 30;
                ops.elem = "#" + ops.id;
                ops.lay_verType = $this.attr('lay_verType');
                if ($.trim(ops.lay_verType) == '') {
                    ops.lay_verType = 'tips';
                }

                if (!ops.type) {
                    ops.type = "date";
                }

                if (!ops.max) {
                    var format = "yyyy-MM-dd";
                    if (ops.type == 'date') {
                        format = "yyyy-MM-dd";
                    } else if (ops.type == 'year') {
                        format = "yyyy";
                    } else if (ops.type == 'month') {
                        format = "yyyy-MM";
                    } else if (ops.type == 'time') {
                        format = "hh:mm:ss";
                    } else if (ops.type == 'datetime') {
                        format = "yyyy-MM-dd hh:mm:ss";
                    }
                    ops.max = own.util.format(new Date(), format);
                }

                var remark_k = $.trim(ops.remark) != '' ? '<i class="layui-icon tip_' + ops.id + ' label_tip layui-icon-about"></i>' : '';
                var input = '<input placeholder="' + (!ops.placeholder ? '' : ops.placeholder) + '" lay-filter="' + ops.id + '" ' + (ops.disabled == undefined ? '' : 'disabled="' + ops.disabled + '"') + ' type="text" readonly="readonly" style="' + (ops.style) + '" id="' + ops.id + '" name="' + ops.name + '" lay-verify="' + ops.lay_verify + '" lay-verType="' + ops.lay_verType + '" class="layui-input ' + ops.class + '">';

                var html = "";
                if (ops.parcel == true) {
                    html = (ops.inline != true ? '<div class="layui-form-item">\n' : '') +
                        (ops.inline == true ? '<div class="layui-inline ' + (ops.parcelclass != undefined ? ops.parcelclass : '') + ' ">' : '') +
                        '            <label class="layui-form-label">' + ops.parcelname + (($.trim(ops.lay_verify).indexOf('required') >= 0) ? '<i class="layui-icon" style="font-size: 15px; color: red;">*</i>' : '') + ((remark_k == '' ? '' : remark_k)) + '</label>\n' +
                        '            <div class="layui-input-block">\n' +
                        input +
                        '            </div>\n' +
                        (ops.inline == true ? '</div>' : '') +
                        (ops.inline != true ? '</div' : '');
                } else {
                    html = input;
                }

                var fun = "";
                if (!ops.change) {

                } else {
                    fun = ops.change;
                }
                ops.change = function (value, d, endDate) {
                    console.log("endData", endDate, value, d);
                    if (endDate != undefined) {
                        if (ops.type == 'date') {
                            var detes = value.split(ops.range);
                            var startTime = new Date(Date.parse(detes[0].replace(/-/g, "/"))).getTime();
                            var endTime = new Date(Date.parse(detes[1].replace(/-/g, "/"))).getTime();
                            var days = Math.abs((startTime - endTime)) / (1000 * 60 * 60 * 24);
                            if (days > ops.rangenum) {
                                ins1.hint("时间差间隔只能是" + ops.rangenum);
                                $('.layui-laydate-footer .laydate-btns-confirm').addClass('laydate-disabled');
                                layui.laydate.clear();
                            }
                        }
                    }
                }
                ops.done = function (value, d, endDate) {
                    if (fun != '') {
                        var fun_ = eval('' + fun + '');
                        fun_.call(null, value, d, endDate);
                    }
                }


                $this.replaceWith(html);
                console.log("时间空间：", ops);
                var ins1 = layui.laydate.render(ops);

                if (remark_k != '') {
                    $('.tip_' + ops.id).mouseover(function () {
                        layer.tips(ops.remark, this);
                    });
                }
            });
        },
        switch: function () {
            $("zxw\\:switch").each(function (i, n) {
                var ops = {};
                var $this = $(this);
                var atts = $this[0].attributes;
                for (var i = 0; i < atts.length; i++) {
                    var name = atts[i].name;
                    var value = atts[i].value;
                    if (value != undefined && value != null && value != '') {
                        ops[name] = value == 'true' ? true : value == 'false' ? false : value;
                    }
                }

                ops.lay_verType = $this.attr('lay_verType');
                if ($.trim(ops.lay_verType) == '') {
                    ops.lay_verType = 'tips';
                }

                var remark_k = $.trim(ops.remark) != '' ? '<i class="layui-icon tip_' + ops.id + ' label_tip layui-icon-about"></i>' : '';
                var input = '<input lay-filter="' + ops.id + '" true_text="' + (ops.true_text == undefined ? 'on' : ops.true_text) + '" lay-skin="switch" lay-text="' + ops.text + '" ' + (ops.disabled == undefined ? '' : 'disabled="' + ops.disabled + '"') + ' type="checkbox" id="' + ops.id + '" name="' + ops.name + '" lay-verify="' + ops.lay_verify + '" lay-verType="' + ops.lay_verType + '" class="layui-input ' + ops.class + '">';

                var html = "";
                if (ops.parcel == true) {
                    html = (ops.inline != true ? '<div class="layui-form-item">\n' : '') +
                        (ops.inline == true ? '<div class="layui-inline ' + (ops.parcelclass != undefined ? ops.parcelclass : '') + ' ">' : '') +
                        '            <label class="layui-form-label">' + ops.parcelname + (($.trim(ops.lay_verify).indexOf('required') >= 0) ? '<i class="layui-icon" style="font-size: 15px; color: red;">*</i>' : '') + ((remark_k == '' ? '' : remark_k)) + '</label>\n' +
                        '            <div class="layui-input-block">\n' +
                        input +
                        '            </div>\n' +
                        (ops.inline == true ? '</div>' : '') +
                        (ops.inline != true ? '</div' : '');
                } else {
                    html = input;
                }

                $this.replaceWith(html);

                layui.form.render();
                layui.form.on('switch(' + ops.id + ')', function (d) {
                    // console.log(d);
                    // // console.log(data.elem); //得到radio原始DOM对象
                    // console.log(d.elem); //得到checkbox原始DOM对象
                    // console.log(d.elem.checked); //开关是否开启，true或者false
                    // console.log(d.value); //开关value值，也可以通过data.elem.value得到
                    // console.log(d.othis); //得到美化后的DOM对象
                    if ($.trim(ops.change) != '') {
                        var fun_ = eval('' + ops.change + '');
                        fun_.call(null, d.elem.checked, d, d.elem, d.value, d.othis);
                    }
                });

                if (remark_k != '') {
                    $('.tip_' + ops.id).mouseover(function () {
                        layer.tips(ops.remark, this);
                    });
                }

            });
        },
        /**
         * 加载img图片查看
         */
        img: function () {
            $('body').on('click', '.showImg', function () {
                var src = $(this).attr('org-src');
                if (src == undefined || src == null) {
                    src = $(this).attr('src');
                }
                window.top.njzxw.showphotos(src);
            });
            $('body').on('click', '.showVide', function () {
                var src = $(this).attr('url');
                if (src == undefined || src == null) {
                    njzxw.alert({
                        error: true,
                        msg: '视频路径丢失'
                    });
                    return;
                }

                window.top.njzxw.layui._showCideo(2, src);


            });
            $('body').on('click', '.showAudio', function () {
                var src = $(this).attr('url');
                if (src == undefined || src == null) {
                    njzxw.alert({
                        error: true,
                        msg: '视频路径丢失'
                    });
                    return;
                }
                window.top.njzxw.layui._showCideo(1, src);

            });

            function closeAudia() {
                alert(3);
            }
        },
        _showCideo: function (type, src) {
            if (type == 1) {
                _audia = layer.open({
                    title: '',
                    content: '<audio onerror="njzxw.layui._closelayer(1);" src="' + src + '" controls="controls" loop="loop" autoplay="autoplay">亲 您的浏览器不支持html5的audio标签</audio>',
                    btn: []
                });
            } else {
                var id = 'cideo' + parseInt(Math.random() * 10000);
                layer.open({
                    title: '',
                    content: '<video onerror="alert(3);" id="' + id + '" width="320" height="240" controls>' +
                        '   <source src="' + src + '" type="video/mp4">' +
                        '   您的浏览器不支持 video 标签。' +
                        '     </video>',
                    btn: []
                });
            }
        },
        /**
         * 不对外开放
         * @private
         */
        _closelayer: function (type) {
            if (type == 1) {
                layer.close(_audia);
                _audia = undefined;
                njzxw.alert({
                    error: true,
                    msg: '加载失败'
                });
            } else {
                layer.close(_audia);
                _audia = undefined;
                njzxw.alert({
                    error: true,
                    msg: '加载失败'
                });
            }
        },
        /**
         * 本地缓存数据
         */
        cache: {
            /**
             * 窗口页面还原值操作
             */
            restore: function () {
                var table = $('#' + window.name, window.parent.document).parent().attr('id');
                var local = layui.data(table);
                if (local != undefined && local != null) {
                    njzxw.layui.val(local.data);
                } else {
                    njzxw.alert({
                        error: true,
                        msg: '数据还原失败，失败原因数据丢失。'
                    })
                }
            },
            get: function (id) {
                var local = layui.data(id);
                return local;
            },
            add: function (id, data) {
                // var table = $('#'+window.name,window.parent.document).parent().attr('id');
                layui.data(id, null);
                layui.data(id, {
                    time: layui.util.toDateString(new Date(), 'yyyy-MM-dd HH:mm:ss'),
                    data: data
                });
            }
        },
        bnt: function () {
            $("zxw\\:bnt").each(function (i, n) {
                var $this = $(this);
                var type = $(this).attr('type');
                var url = $(this).attr('url');
                var title = $(this).attr('title');
                var tableid = $(this).attr('tableid');
                var class_ = $(this).attr('class');
                var fun = $(this).attr('fun');
                var control = $(this).attr('control');
                var msg = $(this).attr('msg');
                var ico = $.trim($(this).attr('ico'));
                var template = $.trim($(this).attr('template'));

                if (!njzxw.checkControl(control)) {
                    return;
                }

                if (type == 'add') {
                    var bnt = $('<button class="layui-btn layui-add ' + $.trim(class_) + ' " ><i class="layui-icon layui-icon-add-circle-fine" ></i>' + title + '</button>');
                    var c = type + '_' + Math.floor(Math.random() * (10000 - 1 + 1) + 1);
                    bnt.addClass(c);
                    $this.replaceWith(bnt);
                    if ($.trim(url) == '') {
                        alert('zxw:bnt标签对应type为add时url参数必填');
                    }
                    $('body').on('click', '.' + c, function () {
                        njzxw.openWindow({
                            id: own.util.hashCode(url),
                            title: title,
                            content: url
                        });
                        return false;
                    });
                } else if (type == 'query') {
                    var bnt = $('<button class="layui-btn layui-query ' + $.trim(class_) + '" ><i class="layui-icon layui-icon-search" ></i>' + title + '</button>');
                    var c = type + '_' + Math.floor(Math.random() * (10000 - 1 + 1) + 1);
                    bnt.addClass(c);
                    $this.replaceWith(bnt);
                    $('body').on('click', '.' + c, function () {
                        if ($.trim(tableid) == '') {
                            tableid = $('zxw\\:table').attr('id');
                        }
                        layui.table.reload(tableid, {
                            page: {
                                pageNum: 1 //重新从第 1 页开始
                            }
                            , where: njzxw.formData($(this).parents('form'))
                        });
                        njzxw.layui.tableToolHide(tableid);
                        return false;
                    });
                } else if (type == 'import') {
                    var bnt = $('<button class="layui-btn layui-import ' + $.trim(class_) + '" ><i class="layui-icon layui-icon-upload-circle" ></i>' + title + '</button>');
                    var c = type + '_' + Math.floor(Math.random() * (10000 - 1 + 1) + 1);
                    bnt.addClass(c);
                    $this.replaceWith(bnt);
                    if ($.trim(template) == '') {
                        alert('zxw:bnt标签对应type为import时template参数必填');
                    }
                    $('body').on('click', '.' + c, function () {
                        // alert(own.config.localhostPath+'/html/import/index.html?saveUrl='+url+"&template="+template);
                        njzxw.openWindow({
                            id: own.util.hashCode(url),
                            title: title,
                            btn: ['导入'],
                            content: own.config.localhostPath + '/html/import/index.html?saveUrl=' + url + "&template=" + template
                        });
                        return false;
                    });
                } else if (type == 'delete') {
                    var bnt = $('<button class="layui-btn layui-query ' + $.trim(class_) + '" ><i class="layui-icon layui-icon-delete" ></i>' + title + '</button>');
                    var c = type + '_' + Math.floor(Math.random() * (10000 - 1 + 1) + 1);
                    bnt.addClass(c);
                    $this.replaceWith(bnt);
                    $('body').on('click', '.' + c, function () {
                        // console.log("数据：",);
                        if ($.trim(tableid) == '') {
                            tableid = $('zxw\\:table').attr('id');
                        }
                        if ($.trim(url) == '') {
                            alert('zxw:bnt标签对应type为add时url参数必填');
                        }
                        var d = $('#' + tableid).data('selectData');
                        d = d == undefined ? [] : d;
                        if (d.length == 0) {
                            njzxw.alert({
                                msg: '没有选择数据哦',
                                error: true
                            });
                        } else {
                            url = url.indexOf('/') >= 0 ? url : eval(url);

                            layui.layer.confirm($.trim(msg) == '' ? '真的删除数据吗？' : msg, function (index) {
                                njzxw.ajax({
                                    url: url,
                                    data: {
                                        ids: d
                                    },
                                    fun: function (a, b) {
                                        if (a) {
                                            if (b.state == 1) {
                                                njzxw.alert({
                                                    msg: b.msg,
                                                    fun: function (a) {
                                                        a();
                                                        layer.close(index);
                                                        $('#' + tableid).data('selectData', []);
                                                        layui.table.reload(tableid, {
                                                            page: {
                                                                pageNum: 1 //重新从第 1 页开始
                                                            }
                                                            , where: njzxw.formData($(this).parents('form'))
                                                        });
                                                        njzxw.layui.tableToolHide(tableid);
                                                    }
                                                })
                                            } else {
                                                njzxw.alert({
                                                    msg: b.msg,
                                                    error: true
                                                })
                                            }
                                        } else {
                                            njzxw.alert({
                                                msg: '操作失败',
                                                error: true
                                            })
                                        }
                                    }
                                })
                            });
                        }

                        return false;
                    });
                } else {
                    var bnt = $('<button class="layui-btn ' + $.trim(class_) + '" ><i class="layui-icon ' + ico + '" ></i>' + title + '</button>');
                    var c = type + '_' + Math.floor(Math.random() * (10000 - 1 + 1) + 1);
                    bnt.addClass(c);
                    $this.replaceWith(bnt);
                    $('body').on('click', '.' + c, function () {
                        if ($.trim(tableid) == '') {
                            tableid = $('zxw\\:table').attr('id');
                        }

                        var d = $('#' + tableid).data('selectData');
                        d = d == undefined ? [] : d;

                        if (d.length == 0) {
                            njzxw.alert({
                                msg: '没有选择数据哦',
                                error: true
                            });
                        } else {
                            if ($.trim(fun) != '') {
                                var fun_ = eval('' + fun_ + '');
                                fun_.call(null, d);
                            } else {
                                url = url.indexOf('/') >= 0 ? url : eval(url);
                                layer.confirm(msg, function (index) {
                                    njzxw.ajax({
                                        url: url,
                                        data: {
                                            ids: d
                                        },
                                        fun: function (a, b) {
                                            if (a) {
                                                if (b.state == 1) {
                                                    njzxw.alert({
                                                        msg: b.msg,
                                                        fun: function (a) {
                                                            a();
                                                            layer.close(index);
                                                            $('#' + tableid).data('selectData', []);
                                                            layui.table.reload(tableid, {
                                                                page: {
                                                                    pageNum: 1 //重新从第 1 页开始
                                                                }
                                                                , where: njzxw.formData($(this).parents('form'))
                                                            });
                                                            njzxw.layui.tableToolHide(tableid);
                                                        }
                                                    })
                                                } else {
                                                    njzxw.alert({
                                                        msg: b.msg,
                                                        error: true
                                                    })
                                                }
                                            } else {
                                                njzxw.alert({
                                                    msg: '操作失败',
                                                    error: true
                                                })
                                            }
                                        }
                                    })
                                });
                            }

                        }
                        return false;
                    });
                }
            });
        },
        /**
         * 初始化赋值操作
         *
         * @param url
         * @param param_name 参数名称，一般指定id的参数名称  如果是ID 则可以不填写，
         * @param data 额外的参数信息
         * @param gather 级联参数
         * @param fun 是否存在额外需要处理信息
         * @param paramExe 是否需要额外处理参数信息，如果需要传入函数
         */
        val: function (opt) {
            //先进行初始化
            this.init();

            var data_ = {};

            if (opt.param_name != undefined && opt.param_name != null) {
                data_[opt.param_name] = njzxw.getQueryParamsString(opt.param_name);
            } else {
                var id = njzxw.getQueryParamsString('id');
                if ($.trim(id) != '') {
                    data_.id = njzxw.getQueryParamsString('id');
                }
            }

            if (opt.data != undefined && opt.data != null) {
                $.extend(data_, opt.data);
            }

            if ($.isEmptyObject(data_)) {
                if (typeof (opt.fun) == 'function') {
                    opt.fun({});
                }
                return;
            }

            $('#id').val($.trim(data_.id));
            var filter = $("*[class*='layui-form']").attr('lay-filter');

            njzxw.data = data_;

            // console.log(data_);

            njzxw.ajax({
                url: opt.url,
                data: data_,
                fun: function (a, b) {
                    if (a) {
                        var data_ = b.data;

                        if (typeof (opt.paramExe) == 'function') {
                            data_ = opt.paramExe(data_);
                        }

                        if (opt.gather != undefined && opt.gather != null) {//存在级联参数
                            for (var i = 0; i < opt.gather.length; i++) {
                                var params = opt.gather[i];
                                try {
                                    $('#' + params + i).data('val', JSON.stringify(data_)).next().find("dd[lay-value='" + (data_[params + i]) + "']").click();
                                } catch (e) {
                                }
                            }
                        }

                        //是否存在复选框
                        if ($.trim(opt.checkbox) != '') {//是否存在复选框需要处理
                            var checkboxs = opt.checkbox.split(',');
                            if (checkboxs.length > 0) {
                                for (var i = 0; i < checkboxs.length; i++) {
                                    var vals = data_[checkboxs[i]];
                                    if ($.trim(vals) != '') {
                                        var vals_ = vals.split(',');
                                        for (var j = 0; j < vals_.length; j++) {
                                            if ($.trim(vals_[j]) != '') {
                                                data_[checkboxs[i] + "[" + vals_[j] + "]"] = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        console.log('初始赋值：', data_);
                        layui.form.val(filter, data_);

                        if (typeof (opt.fun) == 'function') {
                            opt.fun(data_);
                        }

                        //进行重新刷新富文本框
                        $('.layui-layedit iframe').each(function () {
                            var id = $(this).attr('textarea');
                            var index = layui.layedit.build(id, $('#' + id).data('ops'));
                            $('#' + id).data('textareaIndex', index);
                        });
                    } else {
                        layui.layer.alert('数据加载失败');
                    }
                }
            });
        },
        /**
         * 添加表单自定义校验规则
         */
        verify: function (ops) {
            var def = {
                img: function (value, item) {//value：表单的值、item：表单的DOM对象
                    if (value == '') {
                        $(item).focus();
                        return "请选择图片";
                    }
                },
                video: function (value, item) {
                    if (value == '') {
                        $(item).focus();
                        return "请选择视频文件";
                    }
                },
                audio: function (value, item) {
                    if (value == '') {
                        $(item).focus();
                        return "请选择音频文件";
                    }
                },
            };
            $.extend(def, ops);
            layui.form.verify(def);
        },
        /**
         * 提交操作
         * @param url
         * @param params 级联对应的参数信息
         * @param againparams 重新处理form表单参数数据  支持true/false 一般用于表单存在列表时传入true处理处理
         * @param prepFun 重新处理form表单，在提交之前，againparams废弃，不在支持fun函数传入，会有问题
         */
        submit: function (opt) {
            $('form').append('<button class="njzxw-submit" lay-submit lay-filter="_save_"></button>\n' +
                '        <button type="reset" class="njzxw-reset layui-btn layui-btn-primary" ></button>');
            //监听提交
            // console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
            // console.log(data.form) //被执行提交的form对象，一般在存在form标签时才会返回
            // console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}

            layui.form.on('submit(_save_)', function (data) {
                console.log('======', data);
                var index_ = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引

                $('#layui-layer' + index_, window.parent.document).find('.layui-layer-btn0').addClass('layui-disabled').append('<i class="layui-icon-loading layui-icon layui-anim layui-anim-rotate layui-anim-loop" ></i>');

                var data_ = data.field;

                //处理富文本框
                $("iframe[textarea]").each(function () {
                    var textName = $(this).attr('textarea');
                    var index = $('#' + textName).data('textareaIndex');
                    console.log('index', index);
                    if ($.trim(index) != '') {
                        data_[textName] = layui.layedit.getContent(index);
                    }
                });
                $("input[lay-skin='switch']").each(function () {
                    var switchId = $(this).attr('id');
                    var true_text = $(this).attr('true_text');
                    if ($.trim(true_text) == '' || true_text == undefined) {
                        true_text = 'on';
                    }
                    if (data_[switchId] == true_text) {
                        data_[switchId] = 1;
                    } else {
                        data_[switchId] = 0;
                    }
                });

                for (var key in data_) {
                    if (key.indexOf('[') > 0) {
                        var keys = key.split('[');
                        if (!data_.hasOwnProperty(keys[0])) {
                            data_[keys[0]] = keys[1].substr(0, keys[1].length - 1) + ",";
                            data_[keys[0] + "_name"] = $("input[name='" + key + "']").attr('title') + ",";
                        } else {
                            data_[keys[0]] += keys[1].substr(0, keys[1].length - 1) + ",";
                            data_[keys[0] + "_name"] += $("input[name='" + key + "']").attr('title') + ",";
                        }
                    }
                }

                if (opt.params != undefined && opt.params != null) {
                    var end = '';
                    var endlist = '';
                    for (var i = 0; i < opt.params.length; i++) {
                        for (var item in data.field) {
                            if (item.indexOf(opt.params[i]) >= 0) {
                                if ($.trim(data.field[item]) != '') {
                                    end = data.field[item];
                                    endlist += data.field[item] + ",";
                                }
                            }
                        }
                        data_[opt.params[i]] = end;
                        data_[opt.params[i] + "_list"] = endlist;
                    }
                }

                if (opt.againparams == true) {
                    data_ = njzxw.formData('form');
                }

                if (typeof (opt.againparams) == 'function') {
                    data_ = opt.againparams(data_);
                    if (data_ == undefined) {
                        alert('againparams参数设置为函数，未返回数据data');
                        return;
                    }
                    if (data_ == false) {
                        $('#layui-layer' + index_, window.parent.document).find('.layui-layer-btn0').removeClass('layui-disabled').find('i').remove();
                        return false;
                    }
                }
                if (typeof (njzxw.data) != 'undefined') {
                    console.log(njzxw.data, njzxw.data.id);
                    if (njzxw.data.id != undefined && $.trim(njzxw.data.id) != '') {
                        data_.id = njzxw.data.id;
                    }
                } else {
                    var id_ = njzxw.getQueryParamsString('id');
                    if (id_ != undefined && $.trim(id_) != '') {
                        data_.id = id_;
                    }
                }

                if (typeof (opt.prepFun) == 'function') {
                    data_ = opt.prepFun(data_);
                }

                njzxw.ajax({
                    url: opt.url,
                    data: data_,
                    fun: function (a, b) {
                        if (a) {
                            if (typeof (opt.fun) == 'function') {
                                opt.fun(a, b);
                            } else {
                                if (b.state == 1) {
                                    njzxw.alert({
                                        msg: b.msg,
                                        fun: function (a) {
                                            if (njzxw.getQueryParamsString('window') == 'false') {
                                                window.location.reload();
                                            } else {
                                                parent.layer.close(index_); //再执行关闭
                                                if (opt.refresh == undefined) {
                                                    parent.index.refresh();
                                                } else {

                                                }
                                            }
                                        }
                                    })
                                } else {
                                    njzxw.alert({
                                        msg: b.msg,
                                        fun: function (a) {
                                            a();
                                            own.hideLoad();
                                            $('#layui-layer' + index_, window.parent.document).find('.layui-layer-btn0').removeClass('layui-disabled').find('i').remove();
                                        }
                                    });
                                }
                            }
                        } else {
                            njzxw.alert({
                                msg: '提交失败，请稍后再试',
                                fun: function (a) {
                                    a();
                                    own.hideLoad();
                                    $('#layui-layer' + index_, window.parent.document).find('.layui-layer-btn0').removeClass('layui-disabled').find('i').remove();
                                }
                            });
                        }

                    }
                });
                return false;
            });
        },
        textarea: function () {
            $('zxw\\:textarea').each(function (i, n) {
                var ops = {};
                var $this = $(this);
                var atts = $this[0].attributes;
                for (var i = 0; i < atts.length; i++) {
                    var name = atts[i].name;
                    var value = atts[i].value;
                    if (value != undefined && value != null && value != '') {
                        ops[name] = value == 'true' ? true : value == 'false' ? false : value;
                    }
                }

                ops.lay_verType = $this.attr('lay_verType');
                if ($.trim(ops.lay_verType) == '') {
                    ops.lay_verType = 'tips';
                }
                if (!ops.row) ops.row = 5;
                if (!ops.col) ops.col = 12;
                if (ops.height) ops.height = 'height:' + ops.height;

                var remark_k = $.trim(ops.remark) != '' ? '<i class="layui-icon tip_' + ops.id + ' label_tip layui-icon-about"></i>' : '';
                var input = '<textarea row="' + ops.row + '" ' + (ops.maxlength == undefined ? '' : 'maxlength="' + ops.maxlength + '"') + ' id="' + ops.id + '" name="' + ops.name + '" lay-verify="' + (ops.lay_verify == undefined ? '' : ops.lay_verify) + '" lay-verType="' + (ops.lay_verType == undefined ? 'msg' : ops.lay_verType) + '" placeholder="' + (!ops.placeholder ? '' : ops.placeholder) + '" style="' + (ops.style) + '" class="layui-textarea ' + ops.class + '"></textarea>';

                var html = "";
                if (ops.parcel == true) {
                    html = (ops.inline != true ? '<div class="layui-form-item ' + ops.colclass + ' ">\n' : '') +
                        (ops.inline == true ? '<div class="layui-inline ' + (ops.parcelclass != undefined ? ops.parcelclass : '') + ' ">' : '') +
                        '            <label class="layui-form-label">' + ops.parcelname + (($.trim(ops.lay_verify).indexOf('required') >= 0) ? '<i class="layui-icon" style="font-size: 15px; color: red;">*</i>' : '') + ((remark_k == '' ? '' : remark_k)) + '</label>\n' +
                        '            <div class="layui-input-block">\n' +
                        input +
                        '            </div>\n' +
                        (ops.inline == true ? '</div>' : '') +
                        (ops.inline != true ? '</div' : '');
                } else {
                    html = input;
                }

                $this.replaceWith(html);
                if (ops.rich == true) {//富文本框
                    if ($.trim(ops.tool) == '') {
                        ops.tool = [
                            'html', 'undo', 'redo', 'code', 'strong', 'italic', 'underline', 'del', 'addhr', '|', 'fontFomatt', 'fontfamily', 'fontBackColor', 'colorpicker', 'face'
                            , '|', 'left', 'center', 'right', '|', 'link', 'unlink', 'images', 'image_alt', 'video', 'attachment', 'anchors'
                            , '|'
                            , 'table', 'customlink'
                            , 'fullScreen'
                        ]
                    } else {
                        ops.tool = ops.tool.split(',');
                    }
                    // console.log(ops.tool);
                    own.request('ace,layedit', function () {
                        var opss = {
                            tool: ops.tool,
                            height: $.trim(ops.height) == '' ? '200px' : ops.height,
                            uploadImage: {
                                url: URL.INDEX.UPLOADFILETEXT,
                                accept: 'image',
                                acceptMime: 'image/*',
                                exts: 'jpg|png|gif|bmp|jpeg',
                                size: '10240',
                                done: function (data) {
                                    console.log(data);
                                }
                            },
                            uploadVideo: {
                                url: URL.INDEX.UPLOADFILETEXT,
                                accept: 'video',
                                acceptMime: 'video/*',
                                exts: 'mp4|flv|avi|rm|rmvb',
                                size: '20480',
                                done: function (data) {
                                    console.log(data);
                                }
                            },
                            uploadFiles: {
                                url: URL.INDEX.UPLOADFILETEXT,
                                accept: 'file',
                                acceptMime: 'file/*',
                                size: '20480',
                                done: function (data) {
                                    console.log(data);
                                }
                            },
                            devmode: true,
                            codeConfig: {
                                hide: false,  //是否显示编码语言选择框
                                default: 'javascript' //hide为true时的默认语言格式
                            }
                        };
                        var index = layui.layedit.build(ops.id, opss);

                        // console.log("富文本框：",index);
                        $('#' + ops.id).data({'textareaIndex': index, 'ops': opss});
                        layui.layedit.sync(index);
                    });
                }

                if (remark_k != '') {
                    $('.tip_' + ops.id).mouseover(function () {
                        layer.tips(ops.remark, this);
                    });
                }
            });
        },
        input: function () {
            $('zxw\\:input').each(function (i, n) {
                var ops = {};
                var $this = $(this);
                var atts = $this[0].attributes;
                for (var i = 0; i < atts.length; i++) {
                    var name = atts[i].name;
                    var value = atts[i].value;
                    if (value != undefined && value != null && value != '') {
                        ops[name] = value == 'true' ? true : value == 'false' ? false : value;
                    }
                }

                // if(!ops.col)ops.col = 12;
                ops.lay_verType = $this.attr('lay_verType');
                if ($.trim(ops.lay_verType) == '') {
                    ops.lay_verType = 'tips';
                }
                var remark_k = $.trim(ops.remark) != '' ? '<i class="layui-icon tip_' + ops.id + ' label_tip layui-icon-about"></i>' : '';
                var input = '<input value="' + (ops.value != undefined ? ops.value : '') + '" ' + (ops.readonly == undefined ? '' : 'readonly="readonly"') + " " + (ops.maxlength == undefined ? '' : 'maxlength="' + ops.maxlength + '"') + ' type="' + ((ops.type == undefined || ops.type == 'year' || ops.type == 'month' || ops.type == 'date' || ops.type == 'time' || ops.type == 'datetime') ? 'text' : ops.type) + '" id="' + ops.id + '" name="' + ops.name + '" lay-verify="' + ops.lay_verify + '" lay-verType="' + ops.lay_verType + '" placeholder="' + (!ops.placeholder ? '' : ops.placeholder) + '" class="layui-input ' + ops.class + '">';

                var html = "";
                if (ops.parcel == true) {
                    html = (ops.inline != true ? '<div style="" class="layui-form-item ' + (ops.colclass != undefined ? ops.colclass : '') + '">\n' : '') +
                        (ops.inline == true ? '<div class="layui-inline ' + (ops.parcelclass != undefined ? ops.parcelclass : '') + ' ">' : '') +
                        '            <label class="layui-form-label">' + ops.parcelname + (($.trim(ops.lay_verify).indexOf('required') >= 0) ? '<i class="layui-icon" style="font-size: 15px; color: red;">*</i>' : '') + ((remark_k == '' ? '' : remark_k)) + '</label>\n' +
                        '            <div class="' + (ops.inline == true ? 'layui-input-inline' : 'layui-input-block') + '">\n' +
                        input +
                        '            </div>\n' +
                        (ops.inline == true ? '</div>' : '') +
                        (ops.inline != true ? '</div' : '');
                } else {
                    html = input;
                }

                $this.replaceWith(html);
                if (ops.type == 'year' || ops.type == 'month' || ops.type == 'date' || ops.type == 'time' || ops.type == 'datetime') {
                    var dateOps = {
                        elem: document.getElementById(ops.id),
                        type: ops.type
                    };
                    $('#' + ops.id).attr('readonly', 'readonly');
                    if ($.trim(ops.dateopt) != '') {
                        $.extend(dateOps, JSON.parse(ops.dateopt));
                    }

                    console.log(dateOps);

                    layui.laydate.render(dateOps);
                }

                if (remark_k != '') {
                    $('.tip_' + ops.id).mouseover(function () {
                        layer.tips(ops.remark, this);
                    });
                }
            });
        },
        /**
         * 表格组件
         */
        table: function () {

            $('zxw\\:table').each(function (i, n) {
                var ops = {};

                var $this = $(this);

                if (!njzxw.checkControl($this)) {
                    return;
                }

                var class_ = $this.attr('class');
                var height_ = $this.attr('height');
                var url_ = $this.attr('url');
                var page_ = $this.attr('page');
                var done_ = $this.attr('done');
                var limit_ = $this.attr('limit');
                var limits_ = $this.attr('limits');
                var loading_ = $this.attr('loading');
                var text_ = $this.attr('text');
                var initSort_field_ = $this.attr('initSort_field');
                var initSort_type_ = $this.attr('initSort_type');
                var id_ = $this.attr('id');
                var even_ = $this.attr('even');
                var edit_fun_ = $this.attr('edit_fun');
                var select_fun_ = $this.attr('select_fun');
                var sign_fun_ = $this.attr('sign_fun');
                var cellMinWidth_ = $this.attr('cellMinWidth');
                var width_ = $this.attr('width');
                var toolbar_ = $this.attr('toolbar');

                $this.attr('lay-filter', id_);

                ops.elem = '#' + id_;

                var whindex = url_.indexOf('\?');
                if (url_.indexOf('/') == -1) {
                    url_ = eval(whindex > 0 ? url_.substring(0, whindex) : url_);
                }

                if ($.trim(toolbar_) == '') {
                    toolbar_ = '#zxw-table-tool';
                }

                ops.url = url_;

                ops.cellMinWidth = cellMinWidth_ ? cellMinWidth_ : 80;
                ops.page = page_ ? true : page_;
                ops.limit = limit_ ? 10 : limit_;
                ops.limits = limits_ ? limits_ : [10, 20, 30, 40, 50, 60, 70, 80, 90]
                ops.even = true;
                if (!width_) ops.width = width_;
                ops.toolbar = toolbar_;
                ops.defaultToolbar = ['filter', 'print', 'exports'];

                //获取列信息
                var $tr = $this.find('zxw\\:tr');
                var cols = [];
                //进行拼接数据信息
                $tr.each(function (ir, nr) {
                    var tr = [];
                    var $th = $(this).find('zxw\\:th');

                    var checkbox_truth = false;//是否包含选择框列
                    var num_truth = false;//是否已添加序号列
                    var fixld = '';//选择框是否存在固定列，如存在则序号列也需要添加

                    $th.each(function (ih, nh) {
                        var field_th = $(this).attr('field');
                        var width_th = $(this).attr('width');
                        var sort_th = $(this).attr('sort');
                        var minWidth_th = $(this).attr('minWidth');
                        var unresize_th = $(this).attr('unresize');
                        var style_th = $(this).attr('style');
                        var title_th = $(this).attr('title');
                        var edit_th = $(this).attr('edit');
                        var class_th = $(this).attr('class');
                        var type_th = $(this).attr('type');
                        var rowspan = $(this).attr('rowspan');
                        var colspan = $(this).attr('colspan');
                        var fixed = $(this).attr('fixed');

                        var num_th = ih;
                        if (type_th == 'checkbox') {
                            checkbox_truth = true;
                            if (fixed) fixld = fixed;
                        } else if (checkbox_truth) {
                            if (!num_truth) {
                                tr[num_th] = {
                                    type: 'numbers'
                                }

                                if (fixld != '') tr[num_th].fixed = fixld;

                                num_truth = true;
                            }
                            num_th += 1;
                        }

                        var th = {};
                        if (field_th) th.field = field_th;
                        if (title_th) th.title = title_th;
                        if (width_th) th.width = width_th;
                        if (sort_th) th.sort = sort_th == 'true';
                        if (unresize_th) th.unresize = unresize_th;
                        if (minWidth_th) th.minWidth = minWidth_th;
                        if (class_th) th.class = class_th;
                        if (style_th) th.style = style_th;
                        if (type_th) th.type = type_th;
                        if (edit_th) th.edit = edit_th;
                        if (rowspan) th.rowspan = rowspan;
                        if (colspan) th.colspan = colspan;
                        if (fixed) th.fixed = fixed;

                        if (!th.minWidth) {
                            th.minWidth = 150;
                        }

                        if (th.type == 'checkbox') {
                            th.event = 'selcteevent';
                        }

                        //是操作按钮，需要转化语言
                        var $handle = $(this).find('zxw\\:handle');
                        if ($handle.size() > 0) {
                            var con = "";
                            $handle.each(function (ihandle, nhandle) {
                                var $hadle = $(nhandle);
                                var titlehandle = $.trim($hadle.attr('title'));
                                var namehandle = $.trim($hadle.attr('name'));
                                var urlhandle = $.trim($hadle.attr('url'));
                                var classhandle = $.trim($hadle.attr('class'));
                                var funhandle = $.trim($hadle.attr('fun'));
                                var hidehandle = $.trim($hadle.attr('show'));
                                var isshow = $.trim($hadle.attr('isshow'));
                                var warnTitlehandle = $.trim($hadle.attr('warnTitle'));
                                var windowTitle = $.trim($hadle.attr('windowTitle'));

                                var htmlhandle = '<a isshow="' + isshow + '" windowTitle="' + windowTitle + '" warnTitle="' + warnTitlehandle + '" url="' + urlhandle + '" fun="' + funhandle + '" class="layui-btn ' + classhandle + ' layui-btn-xs" lay-event="' + namehandle + '">' + titlehandle + '</a>';

                                if (njzxw.checkControl($hadle)) {
                                    if (hidehandle != '') {
                                        con += '{{# if( ' + hidehandle + ' ){ }}\n';
                                        con += htmlhandle + "\n";
                                        con += '{{#  } }}\n';
                                    } else {
                                        con += htmlhandle + "\n";
                                    }
                                }

                            });
                            th.toolbar = "<div>" + con + "</div>";
                        } else {
                            var thContext = $(this).html().replace(/[\r\n]/g, "").trim();
                            if (thContext.trim() != '') {
                                th.templet = "<div>" + thContext + "</div>";
                            }
                        }

                        tr[num_th] = th;
                    });
                    cols[ir] = tr;
                    ops.cols = cols;
                });
                // console.log('table:',ops);

                $this.attr("lay-filter", id_);

                ops.method = "POST";
                ops.contentType = 'application/json';
                ops.request = {
                    pageName: 'pageNum',
                    limitName: 'pageSize'
                }
                ops.response = {
                    statusName: 'state',
                    statusCode: '1',
                    msgName: 'msg',
                    countName: 'total',
                    dataName: 'data'
                }
                ops.where = njzxw.formData($('.zxw-search'));
                // ops.cellMinWidth = 100;
                // alert($(window).width()-20);
                if (njzxw.isMobile()) {
                    if (!ops.width) ops.width = $(window).width() - 20;
                }
                // console.log(ops);
                var tableObj = layui.table.render(ops);

                $(window).resize(function () {
                    tableObj.resize();
                });

                //监听单元格编辑
                layui.table.on('edit(' + id_ + ')', function (obj) {
                    var value = obj.value //得到修改后的值
                        , data = obj.data //得到所在行所有键值
                        , field = obj.field; //得到字段
                    // layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为：'+ value);
                    var fun = eval('' + edit_fun_ + '');
                    fun.call(null, value, data, field);
                });

                //选择事件
                layui.table.on('checkbox(' + id_ + ')', function (obj) {
                    var data = layui.table.checkStatus(id_).data;
                    if (obj.type == 'all') {//全选
                        if (obj.checked) {
                            var d = [];
                            for (var i = 0, cnt = data.length; i < cnt; i++) {
                                d.push(data[i].id);
                            }
                            $('#' + id_).data('selectData', d);
                        } else {
                            $('#' + id_).data('selectData', []);
                        }
                    } else {
                        var d = $('#' + id_).data('selectData');
                        d = d == undefined ? [] : d;
                        if (obj.checked) {
                            d.push(obj.data.id);
                        } else {
                            for (var i = 0, cnt = d.length; i < cnt; i++) {
                                if (d[i] == obj.data.id) {
                                    d.splice(i, 1);
                                }
                            }
                        }
                        $('#' + id_).data('selectData', d);
                    }
                    if ($.trim(select_fun_) != '') {
                        var fun = eval('' + select_fun_ + '');
                        fun.call(null, state, data, obj.type);
                    }

                });

                own.request('buttonscss,buttonsjs');

                //操作事件
                layui.table.on('tool(' + id_ + ')', function (obj) {

                    var data = obj.data;

                    if (obj.event === 'query') {
                        var fun = $.trim($(obj.tr).find("a[lay-event='query']").attr('fun'));
                        var url = $.trim($(obj.tr).find("a[lay-event='query']").attr('url'));
                        var title = $.trim($(obj.tr).find("a[lay-event='query']").text());
                        var isshow = $.trim($(obj.tr).find("a[lay-event='query']").attr('isshow'));
                        // console.log('===:',data);
                        if (fun != '') {
                            var fun = eval('' + fun + '');
                            fun.call(null, obj);
                        } else {
                            url = (url.indexOf('/') >= 0 ? url : eval(url));
                            if (url.indexOf('?') > 0) {
                                url += '&id=' + data.id;
                            } else {
                                url += '?id=' + data.id;
                            }
                            njzxw.openWindow({
                                id: id_ + data.id,
                                title: '查看' + ($.trim(data.name) != '' ? '【' + data.name + '】' : ''),
                                content: url
                            });
                        }
                    } else if (obj.event === 'delete') {
                        var fun = $.trim($(obj.tr).find("a[lay-event='delete']").attr('fun'));
                        var url = $.trim($(obj.tr).find("a[lay-event='delete']").attr('url'));
                        var msg = $.trim($(obj.tr).find("a[lay-event='delete']").attr('warnTitle'));

                        if (fun != '') {
                            var fun = eval('' + fun + '');
                            fun.call(null, obj);
                        } else {
                            url = url.indexOf('/') >= 0 ? url : eval(url);
                            layer.confirm($.trim(msg) == '' ? '真的删除数据吗？' : msg, function (index) {
                                njzxw.ajax({
                                    url: url,
                                    data: {
                                        ids: [data.id]
                                    },
                                    fun: function (a, b) {
                                        if (a) {
                                            if (b.state == 1) {
                                                njzxw.alert({
                                                    msg: b.msg,
                                                    fun: function (a) {
                                                        a();
                                                        obj.del();
                                                        layer.close(index);
                                                        layui.table.reload(id_, {
                                                            page: {
                                                                pageNum: 1 //重新从第 1 页开始
                                                            }
                                                            , where: njzxw.formData($('.zxw-search').parents('form'))
                                                        });
                                                        njzxw.layui.tableToolHide(id_);
                                                    }
                                                })
                                            } else {
                                                njzxw.alert({
                                                    msg: b.msg,
                                                    error: true
                                                })
                                            }
                                        } else {
                                            njzxw.alert({
                                                msg: '操作失败',
                                                error: true
                                            })
                                        }
                                    }
                                })
                            });
                        }
                    } else if (obj.event === 'edit') {
                        var fun = $.trim($(obj.tr).find("a[lay-event='edit']").attr('fun'));
                        var url = $.trim($(obj.tr).find("a[lay-event='edit']").attr('url'));
                        var isshow = $.trim($(obj.tr).find("a[lay-event='query']").attr('isshow'));
                        if (fun != '') {
                            var fun = eval('' + fun + '');
                            fun.call(null, obj);
                        } else {
                            url = (url.indexOf('/') >= 0 ? url : eval(url));
                            if (url.indexOf('?') > 0) {
                                url += '&id=' + data.id;
                            } else {
                                url += '?id=' + data.id;
                            }
                            njzxw.openWindow({
                                id: id_ + data.id,
                                title: '编辑' + ($.trim(data.name) != '' ? '【' + data.name + '】' : ''),
                                content: url
                            });
                        }
                    } else {
                        if (obj.event == 'selcteevent') {//过来表格前面选择框事件
                            return;
                        }
                        var warnTitle = $.trim($(obj.tr).find("a[lay-event='" + obj.event + "']").attr('warnTitle'));
                        var fun = $.trim($(obj.tr).find("a[lay-event='" + obj.event + "']").attr('fun'));
                        var windowTitle = $.trim($(obj.tr).find("a[lay-event='" + obj.event + "']").attr('windowTitle'));
                        var url = $.trim($(obj.tr).find("a[lay-event='" + obj.event + "']").attr('url'));

                        url = url.indexOf('/') >= 0 ? url : eval(url);

                        if (fun != '') {
                            var fun = eval('' + fun + '');
                            fun.call(null, obj);
                        } else {
                            if (url.lastIndexOf('.html') > 0) {
                                url = (url.indexOf('/') >= 0 ? url : eval(url));
                                if (url.indexOf('?') > 0) {
                                    url += '&id=' + data.id;
                                } else {
                                    url += '?id=' + data.id;
                                }
                                njzxw.openWindow({
                                    id: id_ + data.id,
                                    title: (windowTitle == undefined ? '' : windowTitle) + ($.trim(data.name) != '' ? '【' + data.name + '】' : ''),
                                    content: url
                                });
                            } else {
                                layer.confirm(warnTitle, function (index) {
                                    njzxw.ajax({
                                        url: url,
                                        data: {
                                            ids: [data.id]
                                        },
                                        fun: function (a, b) {
                                            if (a) {
                                                if (b.state == 1) {
                                                    njzxw.alert({
                                                        msg: b.msg,
                                                        fun: function (a) {
                                                            a();
                                                            layer.close(index);
                                                            layui.table.reload(id_, {
                                                                page: {
                                                                    pageNum: 1 //重新从第 1 页开始
                                                                }
                                                                ,
                                                                where: njzxw.formData($('.zxw-search').parents('form'))
                                                            });
                                                            njzxw.layui.tableToolHide(id_);
                                                        }
                                                    })
                                                } else {
                                                    njzxw.alert({
                                                        msg: b.msg,
                                                        error: true
                                                    })
                                                }
                                            } else {
                                                njzxw.alert({
                                                    msg: '操作失败',
                                                    error: true
                                                })
                                            }
                                        }
                                    })
                                });
                            }
                        }
                    }
                });

                //排序事件处理
                layui.table.on('sort(' + id_ + ')', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
                    // console.log(obj.field); //当前排序的字段名
                    // console.log(obj.type); //当前排序类型：desc（降序）、asc（升序）、null（空对象，默认排序）
                    //尽管我们的 table 自带排序功能，但并没有请求服务端。
                    //有些时候，你可能需要根据当前排序的字段，重新向服务端发送请求，从而实现服务端排序，如：
                    layui.table.reload(id_, {
                        initSort: obj //记录初始排序，如果不设的话，将无法标记表头的排序状态。 layui 2.1.1 新增参数
                        , where: { //请求参数（注意：这里面的参数可任意定义，并非下面固定的格式）
                            orderKey: obj.field //排序字段
                            , orderRule: obj.type //排序方式
                        }
                    });
                    njzxw.layui.tableToolHide(id_);
                });

                njzxw.layui.tableToolHide(id_);

            });
        },

        tableToolHide: function (id_) {
            // own.hideLoad();
            var isStop = true;
            var objR = $('#' + id_).next().find('.layui-table-fixed-r');
            if (objR.size() != 0) {
                //将操作按钮收缩到左边
                window.setTimeout(function () {
                    var abnt = $('<a class="zxw-table-r-bnt" >显示操作框</a>');

                    objR.removeClass('layui-hide');
                    objR.prepend(abnt);
                    var width = objR.width();
                    var num = $('#' + id_).next().find(".layui-table-box>.layui-table-header th").size() - 1;
                    $('#' + id_).next().find(".layui-table-box>.layui-table-body td[data-field=" + num + "]").css('opacity', 0);
                    $('#' + id_).next().find(".layui-table-box>.layui-table-header th[data-field=" + num + "]").css('opacity', 0);
                    objR.animate({
                        right: '-' + width + 'px'
                    }, 500, function () {
                        abnt.text('显示操作框');
                        isStop = false;
                    });
                    abnt.mouseover(function () {
                        anim();
                    }).click(function () {
                        anim();
                    });

                    function anim() {
                        if (!isStop) {
                            isStop = true;
                            if (objR.css('right') == '-1px') {
                                objR.animate({
                                    right: '-' + width + 'px'
                                }, 500, function () {
                                    abnt.text('显示操作框');
                                    isStop = false;
                                });
                            } else {
                                objR.animate({
                                    right: '-1px'
                                }, 500, function () {
                                    abnt.text('隐藏操作框');
                                    isStop = false;
                                });
                            }
                        }
                    }

                }, 2000);
            }

        },
        /**
         * 显示
         * @param fieldName 字段名
         * @param src 路径
         */
        showFile: function (fieldName, src) {
            if ($.trim(src) != '') {
                var isMp4 = false;
                var isMp3 = false;
                var type = src.substring(src.lastIndexOf('.') + 1).toLowerCase();
                if (type == 'mp4') {
                    isMp4 = true;
                } else if (type == 'mp3') {
                    isMp3 = true;
                }
                if (src != null && src != undefined) {
                    $('#' + fieldName).val('y' + $('#' + fieldName).val());
                }
                if (isMp4) {
                    $('#' + fieldName + '_img').text(src.substring(src.lastIndexOf('/') + 1)).css({
                        'cursor': 'pointer',
                        'color': 'blue',
                        'text-decoration': 'underline'
                    }).attr('src', src).click(function () {
                        window.open(src);
                    });
                    return;
                } else if (isMp3) {
                    $('#' + fieldName + '_img').text(src.substring(src.lastIndexOf('/') + 1)).css({
                        'cursor': 'pointer',
                        'color': 'blue',
                        'text-decoration': 'underline'
                    }).attr('src', src).click(function () {
                        window.open(src);
                    });
                    return;
                }
                var img = $('<img style="width:38px;height:38px;cursor:pointer;" src="' + src + '" class="layui-upload-img showImg" >');
                $('#' + fieldName + '_img').html(img);
            }

        },
        /**
         * 单文件上传组件
         */
        signUpload: function () {
            $('zxw\\:signUpload').each(function (i, n) {
                var uploadObj = null;
                var $this = $(this);
                var id_ = $this.attr('id');
                var title = $this.attr('title');

                title = title == undefined ? '选择文件' : title;

                var atts = $this[0].attributes;
                var ops = {
                    elem: '#' + id_ + "_bnt"
                };
                console.log(atts);
                for (var i = 0; i < atts.length; i++) {
                    var name = atts[i].name;
                    var value = atts[i].value;
                    if (value != undefined && value != null && value != '') {
                        ops[name] = value == 'true' ? true : value == 'false' ? false : value;
                    }
                }
                if (ops.webupload) {//最新的组件

                    var input = '<div style="height: 0px;" class="layui-upload layui-row">\n' +
                        '                        <div class="layui-col-xs12 layui-col-sm3" >' +
                        '                           <div type="button" class="layui-btn signUpload " id="' + id_ + '_bnt">' + title + '</div>\n' +
                        '                           <input lay-verify="' + ops.lay_verify + '" lay-verType="' + ops.lay_verType + '" type="hidden" name="' + ops.fieldname + '" id="' + ops.fieldname + '" class="layui-input " value="" >' +
                        '                        </div> ' +
                        '                        <div class="layui-upload-wrap layui-col-xs12 layui-col-sm9"  >\n' +
                        '                           <div id="' + id_ + '_img" style="line-height: 38px;width: 100%;overflow: hidden;text-overflow:ellipsis;white-space: nowrap;" ><img style="width: 38px;height: 38px;display: none;" class="layui-upload-img" id="' + id_ + '_img"></div>' +
                        '                        </div>\n' +
                        '                    </div>';

                    var remark_k = $.trim(ops.remark) != '' ? '<i class="layui-icon tip_' + ops.id + ' label_tip layui-icon-about"></i>' : '';
                    var html = "";
                    if (ops.parcel == true) {
                        html = (ops.inline != true ? '<div style="' + (remark_k == '' ? '' : 'margin-bottom:0px;') + '" class="layui-form-item ' + ops.colclass + '">\n' : '') +
                            (ops.inline == true ? '<div class="layui-form-item layui-inline ' + (ops.parcelclass != undefined ? ops.parcelclass : '') + ' ">' : '') +
                            '            <label class="layui-form-label">' + ops.parcelname + (($.trim(ops.lay_verify).indexOf('required') >= 0) ? '<i class="layui-icon" style="font-size: 15px; color: red;">*</i>' : '') + ((remark_k == '' ? '' : remark_k)) + '</label>\n' +
                            '            <div class="' + (ops.inline == true ? 'layui-input-inline' : 'layui-input-block') + '">\n' +
                            input +
                            '            </div>\n' +
                            (ops.inline == true ? '</div>' : '') +
                            (ops.inline != true ? '</div' : '');
                    } else {
                        html = input;
                    }

                    $this.replaceWith(html);

                    // own.request('webUpload',function(){
                    var chunkSize = 3 * 1024 * 1024;
                    var $thelist = $('#thelist');
                    var $btn = $('#ctlBtn');

                    WebUploader.Uploader.register(
                        {
                            beforeSendFile: function (file) {
                                own.addLoad();
                                console.log("beforeSendFile");
                                // Deferred对象在钩子回掉函数中经常要用到，用来处理需要等待的异步操作。
                                var task = new $.Deferred();
                                // 根据文件内容来查询MD5
                                uploader.md5File(file).progress(function (percentage) {   // 及时显示进度
                                    // console.log('计算md5进度:', percentage);
                                    // getProgressBar(file, percentage, "MD5", "MD5");
                                }).then(function (val) { // 完成
                                    // console.log('file:',file);
                                    var md5 = val;
                                    var name = md5 + file.name.substr(file.name.indexOf('.'))
                                    console.log(file);

                                    $('#' + file.bntId + '_img').text(file.name).attr('title', file.name);
                                    file.original_file_name = file.name;
                                    file.name = name;
                                    file.md5 = md5;
                                    // 模拟用户id
                                    // file.uid = new Date().getTime() + "_" + Math.random() * 100;
                                    file.uid = WebUploader.Base.guid();
                                    console.log('file:::::', file);
                                    njzxw.ajax({
                                        url: URL.INDEX.CHECKFILEMD5,
                                        data: {uid: file.uid, md5: file.md5},
                                        fun: function (a, b) {
                                            if (a) {
                                                // var status = data.status.value;
                                                task.resolve();
                                                if (b.state == -2) {//不存在

                                                } else if (b.state == 1) {//上传成功的
                                                    uploader.makeThumb(file, function (error, src) {
                                                        if (error) {
                                                            $('#' + file.bntId + '_img').css({
                                                                'color': 'blue',
                                                                'text-decoration': 'underline'
                                                            }).attr('src', b.path).click(function () {
                                                                window.open(b.path);
                                                            });
                                                            return;
                                                        }
                                                        var img = $('<img org-src="' + b.path + '" src="' + src + '" class="layui-upload-img showImg" >');
                                                        $('#' + file.bntId + '_img').html(img);
                                                    }, 38, 38);
                                                    uploader.skipFile(file);
                                                    file.pass = true;
                                                    file.dataId = b.data;
                                                } else {//部分已经上传到服务器了，但是差几个模块。
                                                    file.missChunks = b.data;
                                                }
                                            }

                                        }
                                    });
                                });
                                return $.when(task);
                            },
                            beforeSend: function (block) {
                                console.log("block")
                                var task = new $.Deferred();
                                var file = block.file;
                                var missChunks = file.missChunks;
                                var blockChunk = block.chunk;
                                if (missChunks !== null && missChunks !== undefined && missChunks !== '') {
                                    var flag = true;
                                    for (var i = 0; i < missChunks.length; i++) {
                                        if (blockChunk == missChunks[i]) {
                                            console.log(file.name + ":" + blockChunk + ":还没上传，现在上传去吧。");
                                            flag = false;
                                            break;
                                        }
                                    }
                                    if (flag) {
                                        task.reject();
                                    } else {
                                        task.resolve();
                                    }
                                } else {
                                    task.resolve();
                                }
                                return $.when(task);
                            }
                        });
                    var url_ = URL.INDEX.BREAKPOINTFILEUPLOAD;

                    var accept = {};
                    var accept_ = $.trim(ops.accept);
                    if (accept_ != '') {
                        if (accept_ == 'images') {
                            accept = {mimeTypes: 'image/*'};
                        } else if (accept_ == 'video') {
                            accept = {
                                title: 'shiooo',
                                mimeTypes: 'video/*'
                            };
                        } else if (accept_ == 'audio') {
                            accept = {
                                mimeTypes: 'audio/*'
                            };
                        }
                    }

                    // 实例化
                    var uploader = WebUploader.create({
                        'before-send-file': 'beforeSendFile',
                        'before-send': 'beforeSend',
                        pick: {
                            id: '#' + id_ + "_bnt",
                            label: title,
                            multiple: false
                        },
                        accept: accept,
                        formData: {
                            uid: 0,
                            md5: '',
                            chunkSize: chunkSize
                        },
                        //dnd: '#dndArea',
                        //paste: '#uploader',
                        swf: 'js/Uploader.swf',
                        chunked: true,
                        chunkSize: chunkSize, // 字节 1M分块
                        chunkRetry: 4,
                        threads: 1,
                        server: url_,
                        auto: false,

                        // 禁掉全局的拖拽功能。这样不会出现图片拖进页面的时候，把图片打开。
                        disableGlobalDnd: true,
                        fileNumLimit: 1024,
                        fileSizeLimit: 1024 * 1024 * 1024,    // 200 M
                        fileSingleSizeLimit: 1024 * 1024 * 1024    // 50 M
                    });
                    // 上传中
                    uploader.on('beforeFileQueued', function (file, percentage) {
                        console.log('===============================1');
                        file.bntId = id_;
                    });

                    // 当有文件被添加进队列的时候
                    uploader.on('fileQueued', function (file) {
                        $('#' + id_ + "_bnt").parent().find('input').attr('disabled', true);
                        $('#' + id_ + "_bnt").addClass('layui-btn-disabled').find('.webuploader-pick').html('上传中0%<b class="layui-icon layui-icon-loading layui-icon layui-anim layui-anim-rotate layui-anim-loop" ></b>');
                        uploader.upload();
                    });

                    //当某个文件的分块在发送前触发，主要用来询问是否要添加附带参数，大文件在开起分片上传的前提下此事件可能会触发多次。
                    uploader.onUploadBeforeSend = function (obj, data) {
                        var file = obj.file;
                        data.md5 = file.md5 || '';
                        data.uid = file.uid;
                        data.original_file_name = file.original_file_name;
                    };
                    // 上传中
                    uploader.on('uploadProgress', function (file, percentage) {
                        var progressPercentage = (percentage * 100).toFixed(2) + '%';
                        $('#' + id_ + "_bnt .webuploader-pick").addClass('layui-btn-disabled').html('上传中' + progressPercentage + '<b class="layui-icon layui-icon-loading layui-icon layui-anim layui-anim-rotate layui-anim-loop" ></b>');

                    });
                    // 上传返回结果
                    uploader.on('uploadSuccess', function (file, response) {
                        console.log('file:111：：', response);
                        console.log(file, response);
                        if (file.pass || (response != null && response.state == 1)) {
                            $('#' + id_ + "_bnt .webuploader-pick").removeClass('layui-btn-disabled').html("上传成功");
                            var id = '';
                            if (response != undefined) {
                                id = response.data;
                            } else {
                                id = file.dataId;
                            }
                            $('#' + ops.fieldname).val(id);
                        } else {
                            $('#' + id_ + "_bnt .webuploader-pick").removeClass('layui-btn-disabled').html("上传失败");
                        }
                        uploader.makeThumb(file, function (error, src) {
                            console.log('==============1========================');
                            var path = '';
                            if (response != undefined) {
                                path = response.path;
                            } else {
                                path = file.path;
                            }
                            if (error) {
                                // $('#imgtd_'+cnt).html( '不能预览' );
                                $('#' + id_ + '_img').css({
                                    'color': 'blue',
                                    'text-decoration': 'underline'
                                }).attr('src', path).click(function () {
                                    window.open(path);
                                });
                                return;
                            }

                            var img = $('<img org-src="' + path + '" src="' + src + '" class="layui-upload-img showImg" >');
                            $('#' + id_ + '_img').html(img);
                        }, 38, 38);
                        $('#' + id_ + "_bnt").removeClass('layui-btn-disabled');
                        uploader.reset();
                    });
                    uploader.on('uploadError', function (file) {
                        $('#' + id_ + "_bnt .webuploader-pick").removeClass('layui-btn-disabled').html("上传错误");
                        $('#' + id_ + "_bnt").removeClass('layui-btn-disabled');
                        uploader.reset();
                    });
                    uploader.on('uploadComplete', function (file) {
                        // 隐藏进度条
                        uploader.reset();
                        $('#' + id_ + "_bnt").removeClass('layui-btn-disabled').parent().find('input').removeAttr('disabled');
                    });
                    // 文件上传
                    $btn.on('click', function () {
                        console.log("上传...");
                        uploader.upload();
                        console.log("上传成功");
                    });

                    // });

                    return;
                }
                ops.multiple = false;
                // ops.url = 'http://localhost:7762/upload';
                // if (!ops.field || ops.field == '') ops.field = 'file';
                ops.field = 'file';
                if (!ops.accept) ops.accept = 'images';
                if (ops.accept == 'images') {
                    ops.acceptMime = 'acceptMime: \'image/*\'';
                }
                if (!ops.size) {
                    ops.size = 1024 * 10
                }
                ;
                ops.number = 1;
                if (!ops.drag) ops.drag = true;
                if (!ops.url) {
                    ops.url = URL.FILE.UPLOADFILE;
                } else {
                    ops.url = eval(ops.url);
                }

                var input = '<div class="layui-upload">\n' +
                    '                        <button type="button" class="layui-btn" id="' + id_ + '_bnt">' + title + '</button>\n' +
                    '                        <input type="hidden" name="' + ops.fieldname + '" id="' + ops.fieldname + '" class="layui-input " value="" > ' +
                    '                        <div class="layui-upload-wrap" style="" >\n' +
                    '                            <div style="display: flex;" >\n' +
                    '                                <img style="width: 38px;height: 38px;display: none;" class="layui-upload-img" id="' + id_ + '_img"><b style="line-height: 38px;margin-left: 5px;" id="' + id_ + '_b" ></b>\n' +
                    '                                <div style="flex: 1;line-height: 38px;" >\n' +
                    '                                    <p id="' + id_ + '_p" style="display: inline-block;" ></p>\n' +
                    '                                </div>\n' +
                    '                            </div>\n' +
                    '                        </div>\n' +
                    '                    </div>';
                var html = (ops.inline != true ? '<div class="layui-form-item ' + ops.colclass + '">\n' : '') +
                    (ops.inline == true ? '<div class="layui-inline ' + (ops.parcelclass != undefined ? ops.parcelclass : '') + ' ">' : '') +
                    '            <label class="layui-form-label">' + ops.parcelname + '</label>\n' +
                    '            <div class="layui-input-block">\n' +
                    input +
                    '            </div>\n' +
                    (ops.inline == true ? '</div>' : '') +
                    (ops.inline != true ? '</div' : '')
                $(this).replaceWith(html);

                function showLoad(type) {
                    if (type) {
                        $('#' + id_ + "_bnt").parent().find('input').attr('disabled', true);
                        $('#' + id_ + "_bnt").addClass('layui-btn-disabled').html('上传中<b class="layui-icon layui-icon-loading layui-icon layui-anim layui-anim-rotate layui-anim-loop" ></b>');
                    } else {
                        $('#' + id_ + "_bnt").parent().find('input').removeAttr('disabled');
                        $('#' + id_ + "_bnt").removeClass('layui-btn-disabled').text(title);
                    }
                }

                ops.before = function (obj) {
                    // own.addLoad();
                    showLoad(true);
                    //预读本地文件示例，不支持ie8
                    obj.preview(function (index, file, result) {
                        $('#' + id_ + '_b').text(file.name); //图片链接（base64）
                        $('#' + id_ + '_img').attr('src', result); //图片链接（base64）
                        if (ops.accept == 'images') {
                            $('#' + id_ + '_img').show();
                        }
                    });
                    var $idp = $('#' + id_ + '_p');
                    $idp.empty();
                }
                ops.done = function (res) {
                    showLoad(false);
                    //如果上传失败
                    if (res.state != 1) {
                        showError();
                        return;
                    }

                    $('#' + ops.fieldname).val(res.data[0].id);
                    if (!ops.fun) {

                    } else {
                        var fun_ = $this.attr('fun');

                        var fun = eval('' + fun_ + '');
                        fun.call(null, res);
                    }

                }
                ops.error = function () {
                    // alert(id_+'_p');
                    //演示失败状态，并实现重传
                    showError();
                    showLoad(false);
                }

                function showError() {
                    var $idp = $('#' + id_ + '_p');
                    $idp.html('<span style="color:#FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs ' + id_ + '-reload">重试</a>');
                    $idp.find('.' + id_ + '-reload').on('click', function () {
                        showLoad(true);
                        uploadObj.upload();
                    });
                }

                // console.log(ops);
                uploadObj = layui.upload.render(ops);

                if (remark_k != '') {
                    $('.tip_' + ops.id).mouseover(function () {
                        layer.tips(ops.remark, this);
                    });
                }
            });
        },
        /**
         * 多文件上传初始化
         */
        multipleUpload: function () {
            $('zxw\\:multipleUpload').each(function (i, n) {
                var $this = $(this);
                var id_ = $this.attr('id');
                var title = $this.attr('title');

                title = title == undefined ? '选择文件' : title;

                var atts = $this[0].attributes;
                var ops = {
                    elem: '#' + id_
                };
                for (var i = 0; i < atts.length; i++) {
                    var name = atts[i].name;
                    var value = atts[i].value;
                    if (value != undefined && value != null && value != '') {
                        ops[name] = value == 'true' ? true : value == 'false' ? false : value;
                    }
                }

                ops.multiple = true;

                if (!ops.field || ops.field == '') ops.field = 'file';
                if (!ops.number || ops.number == '') ops.number = 10;

                if (!ops.accept) ops.accept = 'images';

                ops.auto = false;
                ops.bindAction = '#' + id_ + '_action';
                if (!ops.url || ops.url == '') {
                    ops.url = URL.FILE.UPLOADFILE;
                }
                ;

                if (ops.webupload) {//新的上传方式
                    ops.fileCount = 0;
                    $(this).replaceWith('<div class="layui-upload multipleUpload">\n' +
                        '            <button type="button" style="    padding: 0 0px;" class="layui-btn layui-btn-normal" id="' + id_ + '">' + title + '</button>\n' +
                        '            <div class="layui-upload-list">\n' +
                        '                <table class="layui-table">\n' +
                        '                    <thead>\n' +
                        '                        <tr>\n' +
                        '                            <th>文件名</th>\n' +
                        '                            <th>大小</th>\n' +
                        '                            <th>状态</th>\n' +
                        '                            <th>预览</th>\n' +
                        '                            <th>操作</th>\n' +
                        '                        </tr>\n' +
                        '                    </thead>\n' +
                        '                    <tbody id="' + id_ + '_tbody"></tbody>\n' +
                        '                </table>\n' +
                        '            </div>\n' +
                        '            <button type="button" class="layui-btn" id="' + id_ + '_action">开始上传</button>\n' +
                        '        </div>');

                    var listView = $('#' + id_ + '_tbody');

                    // own.request('webUpload',function(){
                    var chunkSize = 5 * 1024 * 1024;
                    var $thelist = $('#thelist');
                    var $btn = $('#' + id_ + '_action');//上传按钮
                    WebUploader.Uploader.register({
                        'before-send-file': 'beforeSendFile',
                        'before-send': 'beforeSend'
                    }, {
                        beforeSendFile: function (file) {
                            own.addLoad();
                            $btn.hide();
                            // console.log("beforeSendFile");
                            // Deferred对象在钩子回掉函数中经常要用到，用来处理需要等待的异步操作。
                            var task = new $.Deferred();
                            // 根据文件内容来查询MD5
                            uploader.md5File(file).progress(function (percentage) {   // 及时显示进度
                            }).then(function (val) { // 完成
                                var md5 = val;
                                var name = md5 + file.name.substr(file.name.indexOf('.'))
                                console.log('md5 result:', md5, name);
                                file.original_file_name = file.name;
                                file.name = name;
                                file.md5 = md5;
                                // 模拟用户id
                                file.uid = WebUploader.Base.guid();
                                njzxw.ajax({
                                    url: URL.INDEX.CHECKFILEMD5,
                                    data: {uid: file.uid, md5: file.md5},
                                    fun: function (a, b) {
                                        if (a) {
                                            task.resolve();
                                            if (b.state == -2) {//不存在

                                            } else if (b.state == 1) {//上传成功的
                                                uploader.skipFile(file);
                                                file.pass = true;
                                                file.dataId = b.data;
                                            } else {//部分已经上传到服务器了，但是差几个模块。
                                                file.missChunks = b.data;
                                            }
                                        }

                                    }
                                });
                            });
                            return $.when(task);
                        },
                        beforeSend: function (block) {
                            // console.log("block")
                            var task = new $.Deferred();
                            var file = block.file;
                            var missChunks = file.missChunks;
                            var blockChunk = block.chunk;
                            if (missChunks !== null && missChunks !== undefined && missChunks !== '') {
                                var flag = true;
                                for (var i = 0; i < missChunks.length; i++) {
                                    if (blockChunk == missChunks[i]) {
                                        console.log(file.name + ":" + blockChunk + ":还没上传，现在上传去吧。");
                                        flag = false;
                                        break;
                                    }
                                }
                                if (flag) {
                                    task.reject();
                                } else {
                                    task.resolve();
                                }
                            } else {
                                task.resolve();
                            }
                            return $.when(task);
                        }
                    });
                    var url_ = URL.INDEX.BREAKPOINTFILEUPLOAD;
                    // 实例化
                    var uploader = WebUploader.create({
                        pick: {
                            id: '#' + id_
                        },
                        formData: {
                            uid: 0,
                            md5: '',
                            chunkSize: chunkSize
                        },
                        //dnd: '#dndArea',
                        //paste: '#uploader',
                        swf: 'js/Uploader.swf',
                        chunked: true,
                        chunkSize: chunkSize, // 字节 1M分块
                        chunkRetry: 4,
                        threads: 1,
                        server: url_,
                        auto: false,

                        // 禁掉全局的拖拽功能。这样不会出现图片拖进页面的时候，把图片打开。
                        disableGlobalDnd: true,
                        fileNumLimit: 1024,
                        fileSizeLimit: 1024 * 1024 * 1024,    // 200 M
                        fileSingleSizeLimit: 1024 * 1024 * 1024    // 50 M
                    });
                    //点击开始上传按钮
                    $btn.on('click', function () {
                        if (uploader.getFiles().length == 0) {
                            njzxw.alert({
                                error: true,
                                msg: '您还未选择文件哦'
                            })
                            return false;
                        }
                        uploader.upload();
                    });

                    //当问及被添加进队列触发
                    uploader.onFileQueued = function (file) {
                        file.num = uploader.getFiles().length;
                        (function (file, cnt) {
                            $btn.show();
                            $('#' + id_ + "_bnt").parent().find('input').attr('disabled', true);
                            $('#' + id_ + "_bnt").addClass('layui-btn-disabled').find('.webuploader-pick').html('上传中0%<b class="layui-icon layui-icon-loading layui-icon layui-anim layui-anim-rotate layui-anim-loop" ></b>');

                            var tr = $(['<tr id="upload-' + cnt + '">'
                                , '<td>' + file.name + '</td>'
                                , '<td>' + (file.size / 1014).toFixed(1) + 'kb</td>'
                                , '<td id="imgtdfileState_' + cnt + '"  >等待上传</td>'
                                , '<td id="imgtd_' + cnt + '" >预览中</td>'
                                , '<td>'
                                , '<button id="file_reset_upload_bnt_' + cnt + '" class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>'
                                , '<button id="delete_file_' + cnt + '" class="layui-btn layui-btn-xs layui-btn-danger demo-delete">删除</button>'
                                , '</td>'
                                , '</tr>'].join(''));
                            listView.append(tr);
                            uploader.makeThumb(file, function (error, src) {
                                console.log('==============1========================');
                                if (error) {
                                    $('#imgtd_' + cnt).html('不能预览');
                                    return;
                                }
                                var img = $('<img src="' + src + '" class="layui-upload-img" >');
                                $('#imgtd_' + cnt).html(img);
                            }, 38, 38);

                            $('#delete_file_' + cnt).click(function () {
                                tr.remove();
                                uploader.removeFile(file);
                                ops.fileCount--;
                            });
                            $('#file_reset_upload_bnt_' + cnt).click(function () {
                                uploader.upload(file);
                            });
                        })(file, uploader.getFiles().length);
                    }

                    //当某个文件的分块在发送前触发，主要用来询问是否要添加附带参数，大文件在开起分片上传的前提下此事件可能会触发多次。
                    uploader.onUploadBeforeSend = function (obj, data) {
                        var file = obj.file;
                        data.md5 = file.md5 || '';
                        data.uid = file.uid;
                        data.original_file_name = file.original_file_name;
                    };

                    // 上传中
                    uploader.on('uploadProgress', function (file, percentage) {
                        var progressPercentage = (percentage * 100).toFixed(2) + '%';
                        $('#imgtdfileState_' + file.num).html(progressPercentage);
                    });

                    // 上传返回结果
                    uploader.on('uploadSuccess', function (file, response) {
                        console.log('fil11e:', response);
                        console.log("上传1完成...:", uploader.getStats());
                        console.log(file, response);
                        if (file.pass || (response != null && response.state == 1)) {
                            $('#imgtdfileState_' + file.num).html("上传成功");
                            var id = '';
                            if (response != undefined) {
                                id = response.data;
                            } else {
                                id = file.dataId;
                            }
                            $('#' + ops.fieldname).val(id);
                            if (!njzxw.hasOwnProperty(id_)) {
                                njzxw[id_] = [];
                            }
                            njzxw[id_][njzxw[id_].length] = id;
                            $('#file_reset_upload_bnt_' + file.num).addClass('layui-hide');
                        } else {
                            $('#imgtdfileState_' + file.num).html("上传失败");
                            $('#file_reset_upload_bnt_' + file.num).removeClass('layui-hide'); //显示重传
                        }

                    });

                    uploader.on('uploadError', function (file) {
                        $('#imgtdfileState_' + file.num).html("上传失败");
                        $('#file_reset_upload_bnt_' + file.num).removeClass('layui-hide'); //显示重传
                    });

                    return;
                }

                $(this).replaceWith('<div class="layui-upload">\n' +
                    '            <button type="button" class="layui-btn layui-btn-normal" id="' + id_ + '">' + title + '</button>\n' +
                    '            <div class="layui-upload-list">\n' +
                    '                <table class="layui-table">\n' +
                    '                    <thead>\n' +
                    '                        <tr>\n' +
                    '                            <th>文件名</th>\n' +
                    '                            <th>大小</th>\n' +
                    '                            <th>状态</th>\n' +
                    '                            <th>预览</th>\n' +
                    '                            <th>操作</th>\n' +
                    '                        </tr>\n' +
                    '                    </thead>\n' +
                    '                    <tbody id="' + id_ + '_tbody"></tbody>\n' +
                    '                </table>\n' +
                    '            </div>\n' +
                    '            <button type="button" class="layui-btn" id="' + id_ + '_action">开始上传</button>\n' +
                    '        </div>');

                var listView = $('#' + id_ + '_tbody');

                ops.choose = function (obj) {
                    own.addLoad();
                    var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
                    //读取本地文件
                    obj.preview(function (index, file, result) {
                        var tr = $(['<tr id="upload-' + index + '">'
                            , '<td>' + file.name + '</td>'
                            , '<td>' + (file.size / 1014).toFixed(1) + 'kb</td>'
                            , '<td>等待上传</td>'
                            , '<td><img style="width: 38px;height: 38px;" class="layui-upload-img" src="' + result + '"></td>'
                            , '<td>'
                            , '<button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>'
                            , '<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete">删除</button>'
                            , '</td>'
                            , '</tr>'].join(''));

                        //单个重传
                        tr.find('.demo-reload').on('click', function () {
                            obj.upload(index, file);
                            return false;
                        });

                        //删除
                        tr.find('.demo-delete').on('click', function () {
                            delete files[index]; //删除对应的文件
                            tr.remove();
                            uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值，以免删除后出现同名文件不可选
                        });

                        listView.append(tr);
                        own.hideLoad();
                    });
                }

                ops.done = function (res, index, upload) {
                    console.log(res);
                    if (res.state == 1) { //上传成功
                        var tr = listView.find('tr#upload-' + index)
                            , tds = tr.children();
                        tds.eq(2).html('<span style="color: #5FB878;">上传成功</span>');
                        // tds.eq(3).html(''); //清空操作

                        if (!njzxw.hasOwnProperty(id_)) {
                            njzxw[id_] = [];
                        }
                        njzxw[id_][njzxw[id_].length] = res.data[0].id;

                        return delete this.files[index]; //删除文件队列已经上传成功的文件
                    }
                    this.error(index, upload);
                }

                ops.error = function (index, upload) {
                    var tr = listView.find('tr#upload-' + index)
                        , tds = tr.children();
                    tds.eq(2).html('<span style="color: #FF5722;">上传失败</span>');
                    tds.eq(4).find('.demo-reload').removeClass('layui-hide'); //显示重传
                }

                var uploadListIns = layui.upload.render(ops);
            });
        },
        /**
         * 赋值操作
         * @param name
         * @param value
         */
        setVal: function (name, value) {
            var ops_ = {};
            ops_[name] = value;
            var filter = $("*[class*='layui-form']").attr('lay-filter');
            console.log(ops_);
            layui.form.val(filter, ops_);
        },
        /**
         * 下拉组件初始化
         */
        select: function () {
            $('zxw\\:select').each(function () {
                var $this = $(this);
                var ids_ = $this.attr('id');
                var ids = ids_.split(',');
                var id_ = ids[0];

                var atts = $this[0].attributes;
                var ops = {};
                for (var i = 0; i < atts.length; i++) {
                    var name = atts[i].name;
                    var value = atts[i].value;
                    if (value != undefined && value != null && value != '') {
                        ops[name] = value == 'true' ? true : value == 'false' ? false : value;
                    }
                }

                ops.lay_verType = $this.attr('lay_verType');
                if ($.trim(ops.lay_verType) == '') {
                    ops.lay_verType = 'tips';
                }
                //获取url
                var u = ops.url;
                var whindex = u.indexOf('\?');
                var url_ = '';
                var params = '';

                if (ops.isitem) {
                    url_ = URL.ITEM.GETITEM;
                    params = "group_id=" + ops.url;
                } else {
                    url_ = whindex > 0 ? u.substring(0, whindex) : u;
                    params = whindex > 0 ? u.substring(whindex + 1) : '';
                    if (url_.indexOf('/') == -1) {
                        url_ = eval(whindex > 0 ? url_.substring(0, whindex) : url_);
                    }
                }

                if (ops.multiple) {
                    $this.parent().addClass('layui-select-multiple');
                }
                var _id_0 = ((ids.length == 1 && ops.multiple == true) ? id_ + 0 : ids[0]);
                /**
                 * 获取第一个参数值
                 */
                ajax({
                    data: {
                        supper_id: 0
                    },
                    fun: function (a, b, cnt) {
                        if (a) {
                            var namekey = ops.field_name_key.split(',').length == 1 ? ops.field_name_key : ops.field_name_key.split(',')[cnt];
                            var valuekey = ops.field_value_key.split(',').length == 1 ? ops.field_value_key : ops.field_value_key.split(',')[cnt];

                            var html = '<select class="" lay-verify="' + ops.lay_verify + '" lay-verType="' + ops.lay_verType + '" name="' + _id_0 + '" id="' + _id_0 + '" lay-search="" lay-filter="' + _id_0 + '_filter" >' +
                                ((ops.empty_show == undefined || ops.empty_show == 'true') ? '<option value="">请选择...</option>' : '');
                            for (var j = 0; j < b.data.length; j++) {
                                html += '<option value="' + b.data[j][valuekey] + '">' + b.data[j][namekey] + '</option>';
                            }
                            html += '</select>';

                            var html_ = "";

                            var remark_k = $.trim(ops.remark) != '' ? '<i class="layui-icon tip_' + ops.id + ' label_tip layui-icon-about"></i>' : '';
                            var html_ = "";
                            if (ops.parcel == true) {
                                html_ = (ops.inline != true ? '<div style="' + (remark_k == '' ? '' : 'margin-bottom:0px;') + '" class="layui-form-item ' + ops.colclass + '">\n' : '') +
                                    (ops.inline == true ? '<div class="layui-form-item layui-inline ' + (ops.parcelclass != undefined ? ops.parcelclass : '') + ' ">' : '') +
                                    '            <label class="layui-form-label">' + ops.parcelname + (($.trim(ops.lay_verify).indexOf('required') >= 0) ? '<i class="layui-icon" style="font-size: 15px; color: red;">*</i>' : '') + ((remark_k == '' ? '' : remark_k)) + '</label>\n' +
                                    '            <div class="' + (ops.inline == true ? 'layui-input-inline' : 'layui-input-block') + '">\n' +
                                    html +
                                    '            </div>\n' +
                                    (ops.inline == true ? '</div>' : '') +
                                    (ops.inline != true ? '</div' : '');
                            } else {
                                html_ = html;
                            }

                            $this.replaceWith(html_);

                            layui.form.render('select');
                            // if(ops.multiple==true){
                            addEvent(cnt);
                            if (remark_k != '') {
                                $('.tip_' + ops.id).mouseover(function () {
                                    layer.tips(ops.remark, this);
                                });
                            }

                        } else {
                            console.error('select列表加载失败,', url_);
                        }
                    }
                }, 0);

                /**
                 * 添加处理事件
                 * @param num
                 */
                function addEvent(num) {
                    var supperid = ((ids.length == 1 && ops.multiple == true) ? id_ + (num + 0) : ids[num + 0]);
                    layui.form.on('select(' + supperid + '_filter)', function (data) {
                        $('#' + supperid).next().nextAll().remove();
                        var val = data.value;

                        if ($.trim(val) == '') {
                            return;
                        }
                        var truth = true;
                        if (typeof (ops.change) == 'string') {
                            var fun = eval('' + ops.change + '');
                            truth = fun.call(null, data);
                        }
                        if (ops.multiple == true && truth) {
                            ajax({
                                data: {
                                    supper_id: val
                                },
                                fun: function (a, b, cnt) {
                                    if (a) {
                                        if (b.data.length > 0) {
                                            var namekey = ops.field_name_key.split(',').length == 1 ? ops.field_name_key : ops.field_name_key.split(',')[cnt + 1];
                                            var valuekey = ops.field_value_key.split(',').length == 1 ? ops.field_value_key : ops.field_value_key.split(',')[cnt + 1];
                                            var supperid = ((ids.length == 1 && ops.multiple == true) ? id_ + (cnt + 0) : ids[cnt + 0]);
                                            var _id_ = ((ids.length == 1 && ops.multiple == true) ? id_ + (cnt + 1) : ids[cnt + 1]);
                                            var html = '<select class="" lay-verify="' + ops.lay_verify + '" lay-verType="' + ops.lay_verType + '" name="' + _id_ + '" id="' + _id_ + '" lay-search="" lay-filter="' + _id_ + '_filter" >' +
                                                '<option value="">请选择...</option>';
                                            for (var j = 0; j < b.data.length; j++) {
                                                html += '<option value="' + b.data[j][valuekey] + '">' + b.data[j][namekey] + '</option>';
                                            }
                                            html += '</select>';
                                            $('#' + supperid).after(html);

                                            layui.form.render('select');

                                            addEvent(cnt + 1);
                                            try {
                                                //如果第一个存在值就进行赋值操作
                                                var val = JSON.parse($('#' + _id_0).data('val'));
                                                $('#' + _id_).next().find("dd[lay-value='" + val[_id_] + "']").click();
                                            } catch (e) {

                                            }
                                        }
                                    } else {
                                        console.error('select列表加载失败,', url_);
                                    }
                                }
                            }, num);
                        }


                    });
                }

                /**
                 * 进行请求操作
                 *
                 * @param ops
                 */
                function ajax(ops, cnt_) {
                    var data = ops.data;
                    if (params != '') {
                        var params_ = params.split('&');
                        var cnt = params_.length;
                        for (var i = 0; i < cnt; i++) {
                            data[params_[i].split('=')[0]] = params_[i].split('=')[1];
                        }
                    }
                    njzxw.ajax({
                        url: url_,
                        data: data,
                        fun: function (a, b) {
                            ops.fun(a, b, cnt_);
                        }
                    });
                };
            });
        }
    },
    openWindow: function (opt) {
        var hisdata = null;
        var btns = ['<i></i>保存', '重置', '存储为草稿', '还原最近一次存储草稿'];

        //是否显示按钮
        var isShow = false;
        if (opt.title.indexOf('查看') >= 0) {
            isShow = true;
        }

        if (isShow) {
            btns = [];
        }

        var def = {
            id: '',
            title: '系统提示',
            content: null,
            type: 2,
            shade: 0,
            maxmin: true,
            fixed: true,
            cacheFun: null,
            btn: btns,
            scrollbar: false,
            cancel: function (index, layero) {
                return true;
            },
            yes: function (index, layero) {
                if ($.trim(def.id) != '') {
                    $('#' + def.id, window.parent.document).find('iframe').contents().find(".njzxw-submit").click();
                } else {
                    alert('openWindow中的ID未定义');
                }
            },
            btn2: function (index, layero) {
                $('#' + def.id, window.parent.document).find('iframe').contents().find(".njzxw-reset").click();
                return false;
            },
            btn3: function (index, layero) {
                //保存本地数据信息
                try {
                    var cacheFun = def.cacheFun;
                    var fun = $('#' + def.id, window.parent.document).find('iframe')[0].contentWindow.eval(cacheFun);
                    var data = fun.call(null);
                    njzxw.cache.add(def.id, data);
                } catch (e) {
                    // window.我
                    var id = def.id;
                    var win = $('#' + def.id, window.top.document).find('iframe')[0].contentWindow;
                    var datas = win.njzxw.formData('form');
                    njzxw.localStorage.remove(id);
                    njzxw.localStorage.add(id, {
                        time: layui.util.toDateString(new Date(), 'yyyy-MM-dd HH:mm:ss'),
                        data: datas
                    });
                    win.njzxw.alert({
                        msg: '草稿存储成功'
                    });
                }
                return false;
            }
        };

        // if(typeof(hisdata) == 'object') {//存在历史值
        def.btn4 = function (index, layero) {
            var hisdata_ = njzxw.localStorage.get(def.id);
            if (typeof (hisdata_) == 'object' && hisdata != null) {//存在历史值
                var win = $('#' + def.id, window.top.document).find('iframe')[0].contentWindow;
                win.njzxw.alert({
                    msg: '确定要还原时间点[' + hisdata_.time + ']存储的草稿吗？',
                    type: 'confirm',
                    title: '还原提示',
                    fun: function (a) {
                        a();
                        win.njzxw.restore(def.id);
                    }
                });
            } else {
                $('#' + def.id, window.top.document).find('iframe')[0].contentWindow.njzxw.alert({
                    error: true,
                    msg: '暂无数据可还原'
                });
            }
            return false;
        }
        // }

        if (njzxw.isMobile()) {
            // alert($(parent.window).height());
            def.area = ['100%', $(parent.window).height() + 'px'];
            // def.scrollbar = false;
        } else {
            def.area = ['60%', '80%'];
        }
        var resValObj = null;
        def.moveEnd = function (layero) {
            window.top.layer.setTop(layero);
        }
        def.success = function (layero, index) {

            $('#layui-layer' + index + ' .layui-layer-title', window.top.document).append('<b style="font-weight: lighter;" id="b' + def.id + '_b"></b>');
            try {
                hisdata = njzxw.localStorage.get(opt.id);
                console.log('hisdata:', hisdata, "====" + "===" + (typeof (hisdata)));
                if (typeof (hisdata) == 'object' && hisdata != null) {//存在历史值
                    $('#layui-layer' + index + ' .layui-layer-btn3', window.top.document).css('display', 'inline-block');
                }
            } catch (e) {
                console.error(e)
            }

            var h = 0;
            if (njzxw.isMobile()) {
                h = window.top.njzxw.getheight() - 43 - ($('#layui-layer' + index + ' .layui-layer-btn', window.top.document).height() + 22);
            } else {
                h = $('#layui-layer' + index, window.top.document).height() - 43 - ($('#layui-layer' + index + ' .layui-layer-btn', window.top.document).height() + 22);
            }
            $('#layui-layer' + index + ' iframe', window.top.document).css({'height': '100%', 'padding-bottom': '0px'});
            $('#layui-layer' + index + ' .layui-layer-content', window.top.document).css('height', h);
            // }

            if (!isShow) {//只有在编辑状态下才记录草稿
                //执行定时保存草稿，5分钟一次
                resValObj = window.setInterval(function () {
                    try {
                        var cacheFun = def.cacheFun;
                        var fun = $('#' + def.id, window.top.document).find('iframe')[0].contentWindow.eval(cacheFun);
                        var data = fun.call(null);
                        njzxw.cache.add(def.id, data);
                    } catch (e) {
                        // window.我
                        var id = def.id;
                        var datas = $('#' + def.id, window.top.document).find('iframe')[0].contentWindow.njzxw.formData('form');
                        if (!njzxw.checkJsonNull(datas)) {
                            njzxw.localStorage.remove(id);
                            var time = layui.util.toDateString(new Date(), 'yyyy-MM-dd HH:mm:ss');
                            njzxw.localStorage.add(id, {
                                time: layui.util.toDateString(new Date(), 'yyyy-MM-dd HH:mm:ss'),
                                data: datas
                            });
                            $('#b' + def.id + "_b", window.top.document).text("  草稿存储提示：[" + time + "]时间自动存储草稿成功");
                            $('#layui-layer' + index + ' .layui-layer-btn3', window.top.document).css('display', 'inline-block');
                        }
                    }
                }, 3 * 60 * 1000);
            }

            // alert(index);
            // $("#"+"layui-layer-iframe"+index,window.top.document)[0].contentWindow.njzxw.addWindowKey();

            //添加快捷键操作
            // document.onkeydown = function(e){
            //     var keyCode = e.keyCode || e.which || e.charCode;
            //     var ctrlKey = e.metaKey;
            //     console.log(ctrlKey,keyCode);
            //     if(ctrlKey&&keyCode == 82){//刷新 mac
            //         window.location.reload(true);
            //     }else if(ctrlKey&&keyCode == 83){//保存操作
            //         if($.trim(def.id) != ''){
            //             $('#'+def.id,window.parent.document).find('iframe').contents().find(".njzxw-submit").click();
            //         }else{
            //             alert('openWindow中的ID未定义');
            //         }
            //     }else if(ctrlKey&&keyCode == 90){//切换最大最小
            //         if(window.top.index.isMacFrame()){
            //             $('#'+restorebnt).click();
            //         }else{
            //             $('#'+maxFramebnt).click();
            //         }
            //     }
            //     e.preventDefault();
            //     return false;
            // }

        }

        def.full = def.min = def.restore = function (layero) {
            var h = 0;
            var layui_id = $(layero).attr('id');
            if (njzxw.isMobile()) {
                h = window.top.njzxw.getheight() - 43 - ($('#' + layui_id + ' .layui-layer-btn', window.top.document).height() + 22);
            } else {
                h = $('#' + layui_id, window.top.document).height() - 43 - ($('#' + layui_id + ' .layui-layer-btn', window.top.document).height() + 22);
            }
            $('#' + layui_id + ' iframe', window.top.document).css({'height': '100%', 'padding-bottom': '0px'});
            $('#' + layui_id + ' .layui-layer-content', window.top.document).css('height', h);
        }
        def.end = function () {
            if (resValObj != null) {
                window.clearInterval(resValObj);
                resValObj = null;
            }
        }
        $.extend(def, opt);
        window.top.layer.open(def);
    },
    addWindowKey: function () {
        alert(2);
    },
    checkJsonNull: function (json) {
        for (var k in json) {
            if (k != 'token' && k != 'id') {
                if (typeof json[k] == 'string') {
                    console.log('json:::', json[k]);
                    if (json[k] != '') {
                        return false;
                    }
                }
            }
        }
        return true;
    },
    localStorage: {
        add: function (id, value) {
            if (typeof value == 'object') {
                value = JSON.stringify(value);
            }
            localStorage.setItem(id, value);
        },
        get: function (id) {
            var val = localStorage.getItem(id);
            try {
                val = JSON.parse(val);
            } catch (e) {
            }
            return val;
        },
        getYs: function (id) {
            var val = localStorage.getItem(id);
            return val;
        },
        remove: function (id) {
            localStorage.removeItem(id);
        }
    },
    restore: function (id) {
        try {
            var hisdata_ = njzxw.localStorage.get(id);
            if (typeof (hisdata_) == 'object' && hisdata_ != null) {//存在历史值
                var filter = njzxw.getFromFilter();
                console.log(filter, hisdata_.data);
                njzxw.restoreVal(filter, hisdata_.data);
                njzxw.alert({
                    msg: '数据还原成功。'
                });
            }
        } catch (e) {
            console.error(e);
            njzxw.alert({
                error: true,
                msg: '数据还原失败。'
            })
        }

    },
    restoreVal: function (filter, val) {
        console.log(filter, val);
        layui.form.val(filter, val);
    },
    getFromFilter: function () {
        return $("*[class*='layui-form']").attr('lay-filter');
    },
    getheight: function () {
        return $(window).height();
    }
}